hapi.app
Version:
HAPI application generator
20 lines (16 loc) • 610 B
text/coffeescript
{ exec, spawn } = require("child_process")
path = require "path"
fs = require "fs"
runExternalCommand = (targetCommand, cb) ->
unless targetCommand?
throw new Error "wrong number of arguments"
if cb?
unless typeof cb is "function"
throw new Error "callback param should be a function"
callback = cb
unless fs.existsSync targetCommand
throw new Error "external command #{targetCommand} not found!"
c = spawn targetCommand, [], { stdio: "inherit" }
c.on "exit", (code) ->
callback?() or process.exit code
module.exports = runExternalCommand