1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

Use async spawn() by default.

This commit is contained in:
hacksalot
2016-01-12 12:32:32 -05:00
parent 32769a2b0b
commit 07b23109f9
2 changed files with 50 additions and 33 deletions

45
src/utils/safe-spawn.js Normal file
View File

@ -0,0 +1,45 @@
/**
Safe spawn utility for HackMyResume / FluentCV.
@module safe-spawn.js
@license MIT. See LICENSE.md for details.
*/
(function() {
module.exports = function( cmd, args, isSync ) {
try {
var spawn = require('child_process')[ isSync? 'spawnSync' : 'spawn'];
var info = spawn( cmd, args );
if( !isSync ) {
info.on('error', function(err) {
throw {
cmd: 'wkhtmltopdf',
inner: err
};
});
}
else {
if( info.error ) {
throw {
cmd: 'wkhtmltopdf',
inner: info.error
};
}
}
}
catch( ex ) {
}
};
}());