mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-04-19 14:20:25 +01:00
Fix output file name glitch, writing CSS files to destination folder, and an issue where the process would evaporate before PDF/PNG generation could complete.
30 lines
805 B
CoffeeScript
30 lines
805 B
CoffeeScript
###*
|
|
Safe spawn utility for HackMyResume / FluentCV.
|
|
@module utils/safe-spawn
|
|
@license MIT. See LICENSE.md for details.
|
|
###
|
|
|
|
###* Safely spawn a process synchronously or asynchronously without throwing an
|
|
exception ###
|
|
module.exports = ( cmd, args, isSync, callback, param ) ->
|
|
|
|
try
|
|
# .spawnSync not available on earlier Node.js, so default to .spawn
|
|
spawn = require('child_process')[ if isSync then 'spawnSync' else 'spawn']
|
|
info = spawn cmd, args
|
|
|
|
# Check for error depending on whether we're sync or async TODO: Promises
|
|
if !isSync
|
|
info.on 'error', (err) ->
|
|
callback?(err, param)
|
|
return
|
|
return
|
|
else
|
|
if info.error
|
|
callback?(info.error, param)
|
|
return cmd: cmd, inner: info.error
|
|
|
|
catch
|
|
callback?(_error, param)
|
|
_error
|