Skip to content

Instantly share code, notes, and snippets.

@Jeremie-Chauvel
Created May 7, 2020 20:27
Show Gist options
  • Save Jeremie-Chauvel/4ee3681997244274f577d9ea23ab13f4 to your computer and use it in GitHub Desktop.
Save Jeremie-Chauvel/4ee3681997244274f577d9ea23ab13f4 to your computer and use it in GitHub Desktop.
node cli test helper
const path = require('path')
const exec = require('child_process').exec
exports.helpers = {
cli: (args = []) => {
return new Promise((resolve) => {
exec(
`node ${path.resolve('./src/app.js')} ${args.join(' ')}`,
{ cwd: '.' },
(error, stdout, stderr) => {
resolve({
code: error && error.code ? error.code : 0,
error,
stdout,
stderr,
})
}
)
})
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment