Created
May 7, 2020 20:27
-
-
Save Jeremie-Chauvel/4ee3681997244274f577d9ea23ab13f4 to your computer and use it in GitHub Desktop.
node cli test helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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