Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sywac

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sywac - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

34

api.js

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

this._showHelpByDefault = 'showHelpByDefault' in opts ? opts.showHelpByDefault : false
this._strictMode = 'strictMode' in opts ? opts.strictMode : false
this._magicCommandAdded = false

@@ -65,4 +66,4 @@ this._modulesSeen = opts.modulesSeen || []

newChild (commandName) {
return new Api({
newChild (commandName, childOptions) {
return new Api(Object.assign({
factories: this._factories,

@@ -76,4 +77,5 @@ utils: this.utils,

helpOpts: this._assignHelpOpts({}, this.helpOpts),
showHelpByDefault: this._showHelpByDefault
})
showHelpByDefault: this._showHelpByDefault,
strictMode: this._strictMode
}, childOptions))
}

@@ -290,2 +292,20 @@

strict (boolean) {
this._strictMode = boolean !== false
return this
}
addStrictModeErrors (context) {
if (this._strictMode) {
const unknownOptions = context.getUnknownSlurpedOptions()
if (unknownOptions.length > 0) {
context.cliMessage(`Unknown options: ${unknownOptions.map(u => u.raw).join(', ')}`)
}
const unknownArguments = context.getUnknownArguments()
if (unknownArguments.length > 0) {
context.cliMessage(`Unknown arguments: ${unknownArguments.join(' ')}`)
}
}
}
// complex types

@@ -604,2 +624,6 @@ commandDirectory (dir, opts) {

return this.parseFromContext(context).then(whenDone => {
if (!context.commandHandlerRun && !context.output) {
this.addStrictModeErrors(context)
}
if (context.helpRequested && !context.output) {

@@ -640,3 +664,3 @@ context.addDeferredHelp(this.initHelpBuffer())

context.deferHelp().addDeferredHelp(this.initHelpBuffer())
}).configure({ api: this.newChild(Api.DEFAULT_COMMAND_INDICATOR) }, false)
}).configure({ api: this.newChild(Api.DEFAULT_COMMAND_INDICATOR, { strictMode: false }) }, false)
}

@@ -643,0 +667,0 @@

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

this.argv = {}
this.knownArgv = {}
this.details = { args: [], types: [] }

@@ -303,2 +304,3 @@ this.errors = []

this.argv[alias] = tr.value
this.knownArgv[alias] = tr.value
})

@@ -308,2 +310,14 @@ })

getUnknownArguments () {
if (!Array.isArray(this.argv._)) return []
const endOptions = this.argv._.indexOf('--')
return this.argv._.slice(0, endOptions === -1 ? this.argv._.length : endOptions)
}
getUnknownSlurpedOptions () {
return Object.keys(this.argv).filter(key => !(key in this.knownArgv)).map(key => {
return this.slurped.find(arg => arg.parsed.some(p => p.key === key))
})
}
toResult () {

@@ -310,0 +324,0 @@ return {

14

package.json
{
"name": "sywac",
"version": "1.2.2",
"version": "1.3.0",
"description": "So you want a CLI...",

@@ -37,9 +37,9 @@ "main": "index.js",

"devDependencies": {
"chalk": "^2.4.2",
"coveralls": "^3.0.5",
"del": "^5.0.0",
"import-fresh": "^3.1.0",
"standard": "^13.1.0",
"tap": "^14.4.3"
"chalk": "^3.0.0",
"coveralls": "^3.0.9",
"del": "^5.1.0",
"import-fresh": "^3.2.1",
"standard": "^14.3.2",
"tap": "^14.10.6"
}
}

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

context.commandHandlerRun = true
this.api.addStrictModeErrors(context)
if (context.helpRequested || context.messages.length) {

@@ -127,0 +128,0 @@ // console.log('command.js postParse > adding deferred help, implicit:', match.implicit)

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