Socket
Socket
Sign inDemoInstall

@iarna/cli

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iarna/cli - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE

10

app.js

@@ -13,6 +13,10 @@ 'use strict'

let exited = false
onExit(() => {
onExit((code, signal) => {
if (started && !exited) {
console.error('Abnormal exit: Promises not resolved')
process.exit(1)
if (signal) {
console.error('Abnormal exit:', signal)
} else {
console.error('Abnormal exit: Promises not resolved')
}
process.exit(code || 1)
}

@@ -19,0 +23,0 @@ })

{
"name": "@iarna/cli",
"version": "1.0.0",
"description": "",
"version": "1.1.0",
"description": "Some simple CLI scaffolding for promise returning applications.",
"main": "app.js",

@@ -19,3 +19,12 @@ "scripts": {

"app.js"
]
],
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/iarna/cli.git"
},
"bugs": {
"url": "https://github.com/iarna/cli/issues"
},
"homepage": "https://github.com/iarna/cli#readme"
}

@@ -7,6 +7,9 @@ # @iarna/cli

```
`example.js`
```js
require('@iarna/cli')(main)
.boolean('silent')
.boolean('exit')
.boolean('error')
.boolean('reject')
.version()

@@ -18,3 +21,5 @@ .help()

console.log('Got:', arg1, arg2, arg3)
if (opts.exit) process.exit()
if (opts.error) throw new Error('throw')
if (opts.reject) return Promise.reject(new Error('reject'))
return new Promise(resolve => setTimeout(resolve, 10000))

@@ -24,2 +29,36 @@ }

```console
$ node example hello there world
Starting up!
Got: hello there world
$ node example hello there world
Starting up!
Got: hello there world
^C
Abnormal exit: SIGINT
$ node example --silent hello there world
Got: hello there world
$ node example --silent hello there world --exit
Got: hello there world
Abnormal exit: Promises not resolved
$ node example --silent hello there world --error
Abnormal exit: Promises not resolved
Got: hello there world
Error: throw
at main (/Users/rebecca/code/cli/example.js:11:25)
at Immediate.setImmediate (/Users/rebecca/code/cli/app.js:38:32)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
$ node example --silent hello there world --reject
Got: hello there world
Error: reject
at main (/Users/rebecca/code/cli/example.js:12:42)
at Immediate.setImmediate [as _onImmediate] (/Users/rebecca/code/cli/app.js:38:32)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
$
```
## WHAT YOU GET

@@ -59,3 +98,4 @@

Your entry point function should look like this:
Your entry point function can be named anything, but it needs to return a
promise and it takes arguments like this:

@@ -62,0 +102,0 @@ `main(opts, arg1, arg2, …, argn) → Promise`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc