child_process#execFile JavaScript Examples

The following examples show how to use child_process#execFile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: png.js    From ucompress with ISC License 6 votes vote down vote up
optimize = (source, dest) => new Promise((res, rej) => {
  execFile(pngquant, pngquantArgs.concat(dest, source), err => {
    if (err) {
      copyFile(source, dest, err => {
        if (err) rej(err);
        else res(dest);
      });
    }
    else
      res(dest);
  });
})
Example #2
Source File: zip.js    From stolen-sword with MIT License 6 votes vote down vote up
zip = () => ({
  name: 'zip',
  generateBundle(_, bundle) {
    const distPath = path.join(__dirname, '..', 'dist');
    const zipPath = path.join(distPath, 'index.zip');
    const { source } = bundle['index.html'];

    if (!fs.existsSync(distPath)) fs.mkdirSync(distPath);
    
    new JSZip()
      .file('index.html', source)
      .generateNodeStream({
        type:'nodebuffer',
        compression: "DEFLATE",
        compressionOptions: {
          level: 9
        }
      })
      .pipe(fs.createWriteStream(zipPath))
      .on('finish', () => {
        execFile(advzip, ['--recompress', '--shrink-extra', zipPath], err => {
          console.log(err ? err : 'ZIP file minified!', filesize(fs.statSync(zipPath).size));
          execFile(path.join(__dirname, 'ect'), ['-8', '-zip', zipPath], (err, stdout, stderr) => {
            console.log(err ? stderr : stdout);
            console.log(`File size: ${filesize(fs.statSync(zipPath).size)}\n`);
          });
        });
      });
  }
})
Example #3
Source File: index.js    From v8-deopt-viewer with MIT License 5 votes vote down vote up
execFileAsync = promisify(execFile)