mafeifan
6/2/2018 - 2:37 PM

a helper function for Node exec shell script file

a helper function for Node exec shell script file

/*
 const { stdout, stderr } = execShell('scripts/hexo.sh');
  if (stderr) {
    res.send('error');
  }
  ...
*/  
async function execShell(scriptPath) {
  const execFile = require('util').promisify(require('child_process').execFile);
  return await execFile('sh', [scriptPath]);
}