core/postinstall.js
function findSuitableTempDirectory(npmConf) {
  const now = Date.now();
  const candidateTmpDirs = [
    process.env.TMPDIR || process.env.TEMP || npmConf.get('tmp'),
    path.join(process.cwd(), 'tmp',
      '/tmp')
  ];

  for (let i = 0; i < candidateTmpDirs.length; i++) {
    const candidatePath = path.join(candidateTmpDirs[i], 'galenframework');

    try {
      fs.mkdirsSync(candidatePath, '0777');
      // Make double sure we have 0777 permissions; some operating systems
      // default umask does not allow write by default.
      fs.chmodSync(candidatePath, '0777');
      const testFile = path.join(candidatePath, now + '.tmp');
      fs.writeFileSync(testFile, 'test');
      fs.unlinkSync(testFile);
      return candidatePath;
    } catch (e) {
      log.info(candidatePath, 'is not writable:', e.message);
    }
  }

  log.error('Can not find a writable tmp directory.');
  exit(1);
}
function findSuitableTempDirectory(npmConf) {
  const now = Date.now();
  const candidateTmpDirs = [
    process.env.TMPDIR || process.env.TEMP || npmConf.get('tmp'),
    path.join(process.cwd(), 'tmp',
      '/tmp')
  ];

  for (let i = 0; i < candidateTmpDirs.length; i++) {
    const candidatePath = path.join(candidateTmpDirs[i], 'galenframework');

    try {
      fs.mkdirsSync(candidatePath, '0777');
      // Make double sure we have 0777 permissions; some operating systems
      // default umask does not allow write by default.
      fs.chmodSync(candidatePath, '0777');
      const testFile = path.join(candidatePath, now + '.tmp');
      fs.writeFileSync(testFile, 'test');
      fs.unlinkSync(testFile);
      return candidatePath;
    } catch (e) {
      log.info(candidatePath, 'is not writable:', e.message);
    }
  }

  log.error('Can not find a writable tmp directory.');
  exit(1);
}
function findSuitableTempDirectory ( npmConf ) { const now = Date . now ( ) ; const candidateTmpDirs = [ process . env . TMPDIR || process . env . TEMP || npmConf . get ( 'tmp' ) , path . join ( process . cwd ( ) , 'tmp' , '/tmp' ) ] ; for ( let i = 0 ; i < candidateTmpDirs . length ; i ++ ) { const candidatePath = path . join ( candidateTmpDirs [ i ] , 'galenframework' ) ; try { fs . mkdirsSync ( candidatePath , '0777' ) ; // Make double sure we have 0777 permissions; some operating systems // default umask does not allow write by default. fs . chmodSync ( candidatePath , '0777' ) ; const testFile = path . join ( candidatePath , now + '.tmp' ) ; fs . writeFileSync ( testFile , 'test' ) ; fs . unlinkSync ( testFile ) ; return candidatePath ; } catch ( e ) { log . info ( candidatePath , 'is not writable:' , e . message ) ; } } log . error ( 'Can not find a writable tmp directory.' ) ; exit ( 1 ) ; }
Function to find an writable temp directory
@param {object} npmConf - current NPM configuration
@returns {string} representing suitable temp directory
@function
Function to find an writable temp directory