mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-08-14 20:41:01 +01:00
Finish HackMyCore reshaping.
Reintroduce HackMyCore, dropping the interim submodule, and reorganize and improve tests.
This commit is contained in:
28
src/utils/safe-spawn.coffee
Normal file
28
src/utils/safe-spawn.coffee
Normal file
@@ -0,0 +1,28 @@
|
||||
###*
|
||||
Safe spawn utility for HackMyResume / FluentCV.
|
||||
@module utils/safe-spawn
|
||||
@license MIT. See LICENSE.md for details.
|
||||
###
|
||||
|
||||
module.exports = ( cmd, args, isSync, callback ) ->
|
||||
|
||||
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
|
||||
if !isSync
|
||||
info.on 'error', (err) ->
|
||||
if callback? then callback err; return
|
||||
else throw cmd: cmd, inner: err
|
||||
return
|
||||
else
|
||||
if info.error
|
||||
if callback? then callback err; return
|
||||
else throw cmd: cmd, inner: info.error
|
||||
|
||||
catch
|
||||
if callback? then callback _error
|
||||
else throw _error
|
Reference in New Issue
Block a user