Comparing version 0.1.0 to 0.2.0
@@ -62,2 +62,14 @@ "use strict"; | ||
function _default(callback, opts, notifierOpts) { | ||
const defaultConfigFile = opts.defaultConfigFile; | ||
if (defaultConfigFile) { | ||
opts = Object.assign({}, opts); | ||
opts.flags = Object.assign({}, opts.flags); | ||
opts.flags.config = { | ||
type: "string", | ||
alias: "c", | ||
default: defaultConfigFile | ||
}; | ||
} | ||
const cli = meow(opts); | ||
@@ -69,3 +81,10 @@ | ||
if (defaultConfigFile) { | ||
try { | ||
cli.config = require(require("path").resolve(cli.flags.config)); | ||
} catch (e) {// Ignore | ||
} | ||
} | ||
callback(cli); | ||
} |
{ | ||
"name": "@quase/cli", | ||
"version": "0.1.0", | ||
"description": "Cli", | ||
"version": "0.2.0", | ||
"description": "A simple cli helper.", | ||
"license": "MIT", | ||
@@ -14,5 +14,5 @@ "homepage": "https://github.com/quase/quasejs", | ||
"is-installed-globally": "^0.1.0", | ||
"meow": "https://github.com/sindresorhus/meow.git#master", | ||
"meow": "https://github.com/sindresorhus/meow.git#4f7ded3d6b8349fc8514b672a7d5deca2d5f2e98", | ||
"update-notifier": "^2.3.0" | ||
} | ||
} |
## About | ||
It's like `meow` but includes `update-notifier`. | ||
A simple cli helper. | ||
We also change the update message if Yarn is detected. | ||
Includes `meow` and `update-notifier` with some extensions: | ||
- We change the update message if Yarn is detected. | ||
- Passing a `defaultConfigFile` value automates the requiring of a config file. The user will be able to override the default using `--config=another-file.js`. | ||
## Usage example | ||
`bin/my-name` | ||
`bin/index.js` | ||
```js | ||
#!/usr/bin/env node | ||
"use strict"; | ||
require( "@quase/cli" )( | ||
( { input, flags, pkg, help, showHelp } ) => { | ||
require( "@quase/cli" ).default( | ||
( { input, flags, pkg, help, config /* the config object, if "defaultConfigFile" was used */ } ) => { | ||
}, | ||
{}, // Meow options | ||
{ | ||
defaultConfigFile: "config.js" | ||
}, // Meow options + optional defaultConfigFile | ||
{ | ||
options: {}, // UpdateNotifier options | ||
@@ -31,7 +35,5 @@ notify: {} // .notify() options | ||
{ | ||
... | ||
"bin": { | ||
"my-name": "bin/my-name" | ||
"my-name": "bin/index.js" | ||
}, | ||
... | ||
} | ||
@@ -43,1 +45,16 @@ ``` | ||
See https://github.com/yeoman/update-notifier for details. | ||
## Copy-paste example | ||
`bin/index.js` | ||
```js | ||
#!/usr/bin/env node | ||
/* eslint-disable no-shebang */ | ||
require( "@quase/cli" ).default( ( { flags, pkg, config } ) => { | ||
require( "../dist" ).default( Object.assign( {}, config || pkg[ "my-name" ], flags ) ); | ||
}, { | ||
defaultConfigFile: "my-name-config.js" | ||
} ); | ||
``` |
@@ -56,2 +56,15 @@ const chalk = require( "chalk" ); | ||
export default function( callback, opts, notifierOpts ) { | ||
const defaultConfigFile = opts.defaultConfigFile; | ||
if ( defaultConfigFile ) { | ||
opts = Object.assign( {}, opts ); | ||
opts.flags = Object.assign( {}, opts.flags ); | ||
opts.flags.config = { | ||
type: "string", | ||
alias: "c", | ||
default: defaultConfigFile | ||
}; | ||
} | ||
const cli = meow( opts ); | ||
@@ -63,3 +76,11 @@ | ||
if ( defaultConfigFile ) { | ||
try { | ||
cli.config = require( require( "path" ).resolve( cli.flags.config ) ); | ||
} catch ( e ) { | ||
// Ignore | ||
} | ||
} | ||
callback( cli ); | ||
} |
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
6208
136
59
0
3