package
Testable CLIs with promises
npm install exec-promiseGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 4 packages.
21.4 kB
Includes dependencies.
Testable CLIs with promises
Features
TODO
Download manually or with package-manager.
npm install --save exec-promiseThis library requires promises support, for Node versions prior to 0.12 see this page to enable them.
import execPromise from 'exec-promise'
// - The command line arguments are passed as first parameter.
// - Node will exists as soon as the promise is settled (with a code
// different than 0 in case of an error).
// - All errors are catched and properly displayed with a stack
// trace.
// - Any returned value (i.e. not undefined) will be prettily
// displayed
execPromise(async args => {
// ... do what you want here!
})module.exports = function (args) {
if (args.indexOf('-h') !== -1) {
return 'Usage: my-program [-h | -v]'
}
if (args.indexOf('-v') !== -1) {
var pkg = require('./package')
return 'MyProgram version ' + pkg.version
}
var server = require('http').createServer()
server.listen(80)
// The program will run until the server closes or encounters an
Contributions are very welcome, either on the documentation or on the code.
You may:
ISC © Julien Fontanet
marsaud
marsaud.fabrice@neuf.fr