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 2.0.2 to 2.1.0

15

app.js

@@ -5,2 +5,3 @@ 'use strict'

const fs = require('fs')
const process = require('process')
const binName = path.basename(require.main.filename, '.js')

@@ -44,10 +45,18 @@ const mainPath = path.resolve(require.main.paths[0], '..')

let opts
let argv
let argv = process.argv.slice(2)
if (process.platform === 'win32') {
const glob = require('glob').sync
const cwd = process.cwd()
const statCache = {}
const nonull = true
const expandedArgs = []
argv.forEach(_ => expandedArgs.push.apply(expandedArgs, glob(_, {cwd, statCache, nonull})))
argv = expandedArgs
}
try {
/* istanbul ignore next */
if (global['NO_YARGS']) throw new Error('NO YARGS')
yargs = require('yargs')
yargs = require('yargs')(argv)
haveYargs = true
} catch (_) {
argv = process.argv.slice(2)
opts = {_: argv}

@@ -54,0 +63,0 @@ const noYargs = () => {

7

package.json
{
"name": "@iarna/cli",
"version": "2.0.2",
"version": "2.1.0",
"description": "Some simple CLI scaffolding for promise returning applications.",

@@ -13,3 +13,4 @@ "main": "app.js",

"dependencies": {
"signal-exit": "^3.0.2"
"signal-exit": "^3.0.2",
"glob": "^7.1.2"
},

@@ -22,3 +23,3 @@ "files": [

"@perl/qx": "^1.0.2",
"glob": "^7.1.2",
"require-inject": "^1.4.4",
"tap": "^12.0.1",

@@ -25,0 +26,0 @@ "update-notifier": "^2.2.0",

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

### Without Yargs
If you don't have yargs installed as a dependency then you get arguments
split out but no option parsing:
`example.js`

@@ -29,7 +24,30 @@ ```js

### With Yargs
## WHAT YOU GET
If you do have yargs installed as a dependency you can customize it further
by chaining off the require in the usual yargsish way.
* Automatic glob parsing on Windows so that your passing `*.foo` works the
same on Mac/Linux/Windows.
* Error detetion and handling:
* _exit without resolving warnings_ - If your program finishes without
resolving its promises (like if it crashes hard or you process.exit, or
you just don't resolve the promise) then we warn about that.
* If your entry point function rejects then that's reported with a stack
trace (if the rejected value has `.stack`) else with the rejected value
and your process will exit with an error code.
* Optional `yargs` support. If `yargs` is requirable then it will be used.
The wrapper around the main function returns a yargs object, so you can
configure it as usual. The `argv` object is passed in as the first
argument of your entry point function. The rest of your positional
arguments are passed in as the remaining function arguments.
* Optional `update-notifier` support. If `update-notifier` is requirable
then it will be used. A default update notifier is setup for your app so
users will learn about new versions when you publish them. Your app needs
to have a name, version and bin entry in its `package.json`. (The bin
entry needs to have the script using `@iarna/cli` in it for the update
notifier to trigger.)
## With Yargs
If you have yargs installed as a dependency you can customize it further by
chaining off the require in the usual yargsish way.
`example.js`

@@ -99,22 +117,2 @@ ```js

## WHAT YOU GET
* _exit without resolving warnings_ - If your program finishes without
resolving its promises (like if it crashes hard or you process.exit, or you just don't resolve the promise ) then
we warn about that.
* If your entry point function rejects then that's reported with a stack
trace (if the rejected value has `.stack`) else with the rejected value
and your process will exit with an error code.
* If you add `yargs` as a dependency then it will be taken advantage of.
The wrapper around the main function returns a yargs object, so you can
configure it as usual. The `argv` object is passed in as the first
argument of your entry point function. The rest of your positional
arguments are passed in as the remaining function arguments.
* If you add `update-notifier` as a dependency then it will be taken
advantage of. A default update notifier is setup for your app so users
will learn about new versions when you publish them. Your app needs to
have a name, version and bin entry in its `package.json`. (The bin entry
needs to have the script using `@iarna/cli` in it for the update notifier
to trigger.)
## WHAT ITS NOT

@@ -121,0 +119,0 @@

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