New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sergeant

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sergeant - npm Package Compare versions

Comparing version 19.1.2 to 19.2.0

4

error.js

@@ -13,5 +13,5 @@ const chalk = require('chalk')

stack.map((line) => line.match(/^(.*?)(\(.*\))?$/)).forEach(function (parts) {
for (let parts of stack.map((line) => line.match(/^(.*?)(\(.*\))?$/))) {
console.error(chalk.gray(parts[1]) + (parts[2] != null ? parts[2] : ''))
})
}
} else {

@@ -18,0 +18,0 @@ console.error(chalk.red(error.toString()))

@@ -5,3 +5,3 @@ const chalk = require('chalk')

module.exports = function (name, description, {options, parameters, commands}) {
module.exports = async function (name, description, {options, parameters, commands}) {
process.exitCode = 1

@@ -60,3 +60,3 @@

parameters.forEach(function (definition) {
for (let definition of parameters) {
const description = [spaces(longestParameter - definition.key.length) + definition.key]

@@ -68,8 +68,12 @@

if (definition.type != null && definition.type() != null) {
description.push('[default: ' + JSON.stringify(definition.type()) + ']')
if (definition.type != null) {
const _default = await definition.type()
if (_default != null) {
description.push('[default: ' + JSON.stringify(_default) + ']')
}
}
console.error(description.join(' '))
})
}
}

@@ -88,3 +92,3 @@

options.forEach(function (definition) {
for (let definition of options) {
const signature = getSignature(definition)

@@ -97,8 +101,12 @@ const description = [spaces(longestOption - signature.length) + signature]

if (definition.type != null && definition.type() != null) {
description.push('[default: ' + JSON.stringify(definition.type()) + ']')
if (definition.type != null) {
const _default = await definition.type()
if (_default != null) {
description.push('[default: ' + JSON.stringify(_default) + ']')
}
}
console.error(description.join(' '))
})
}
}

@@ -115,5 +123,5 @@

commands.forEach(function (command) {
for (let command of commands) {
console.error(command.name + (command.description ? ' ' + spaces(longestCommand - command.name.length) + chalk.gray(command.description != null ? command.description : '') : ''))
})
}
}

@@ -120,0 +128,0 @@

@@ -23,3 +23,3 @@ const parse = require('./parse')

return function (argv) {
return async function (argv) {
const filtered = argv.filter((arg) => arg !== '-' && !arg.startsWith('-'))

@@ -35,3 +35,3 @@ const command = commands.find((command) => command.name === filtered[0])

} else {
const args = parse(argv, {options, parameters})
const args = await parse(argv, {options, parameters})

@@ -38,0 +38,0 @@ try {

{
"name": "sergeant",
"version": "19.1.2",
"version": "19.2.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -5,3 +5,3 @@ const chalk = require('chalk')

module.exports = function (argv, {options, parameters}) {
module.exports = async function (argv, {options, parameters}) {
try {

@@ -17,5 +17,5 @@ argv = argv.slice(0)

if (definition.aliases) {
definition.aliases.forEach(function (alias) {
for (let alias of definition.aliases) {
options.push(Object.assign({}, definition, {key: alias, alias: true}))
})
}
}

@@ -64,3 +64,3 @@

for (let i = 0; i < argv.length; i++) {
options.forEach(function (definition) {
for (let definition of options) {
const search = addDashes(definition.key)

@@ -103,6 +103,6 @@ const property = definition.property

}
})
}
}
options.filter((option) => options.alias !== true).forEach(function (definition) {
for (let definition of options.filter((option) => options.alias !== true)) {
const property = definition.property

@@ -112,3 +112,3 @@

if (definition.type != null) {
const _default = definition.type()
const _default = await definition.type()

@@ -126,5 +126,5 @@ if (_default != null) {

} else if (definition.type != null) {
args[property] = definition.type(args[property])
args[property] = await definition.type(args[property])
}
})
}

@@ -139,7 +139,7 @@ argv = argv.reduce(function (argv, arg, i) {

argv.forEach(function (arg) {
for (let arg of argv) {
if (arg.startsWith('-') && !arg.startsWith('---')) {
throw new Error('unknown option ' + arg.split('=')[0])
}
})
}

@@ -154,9 +154,11 @@ const remainder = argv.concat(afterDashDash).filter((arg) => arg !== '')

parameters.forEach(function (definition, key) {
let remainingKeys = parameters.length
for (let definition of parameters) {
const property = definition.property
const remainingKeys = parameters.length - 1 - key
remainingKeys -= 1
if (!remainder.length) {
if (definition.type != null) {
const _default = definition.type()
const _default = await definition.type()

@@ -175,10 +177,10 @@ if (_default != null) {

if (definition.type != null) {
args[property] = definition.type(args[property])
args[property] = await definition.type(args[property])
}
} else if (definition.type != null) {
args[property] = definition.type(remainder.shift())
args[property] = await definition.type(remainder.shift())
} else {
args[property] = remainder.shift()
}
})
}

@@ -185,0 +187,0 @@ return args

@@ -10,3 +10,3 @@ const test = require('tape')

test('test ./parse', function (t) {
test('test ./parse', async function (t) {
const parse = require('./parse')

@@ -17,3 +17,3 @@

// test dashdash and parameter
t.deepEquals({'test': '-a'}, parse(['--', '-a'], {
t.deepEquals({'test': '-a'}, await parse(['--', '-a'], {
options: [],

@@ -26,3 +26,3 @@ parameters: [{

// test dashdash and parameter with type
t.deepEquals({'test': 123}, parse(['--', '123'], {
t.deepEquals({'test': 123}, await parse(['--', '123'], {
options: [],

@@ -36,3 +36,3 @@ parameters: [{

// test non-required parameter
t.deepEquals({}, parse([], {
t.deepEquals({}, await parse([], {
options: [],

@@ -45,6 +45,6 @@ parameters: [{

// test empty
t.deepEquals({}, parse([''], {options: [], parameters: []}))
t.deepEquals({}, await parse([''], {options: [], parameters: []}))
// test short
t.deepEquals({aaA: true}, parse(['-a'], {
t.deepEquals({aaA: true}, await parse(['-a'], {
parameters: [],

@@ -58,3 +58,3 @@ options: [{

// test short with value
t.deepEquals({aaA: 'bcd'}, parse(['-a=bcd'], {
t.deepEquals({aaA: 'bcd'}, await parse(['-a=bcd'], {
parameters: [],

@@ -69,3 +69,3 @@ options: [{

// test multiple short with value
t.deepEquals({aaA: 'bcd', b: true}, parse(['-ba=bcd'], {
t.deepEquals({aaA: 'bcd', b: true}, await parse(['-ba=bcd'], {
parameters: [],

@@ -83,3 +83,3 @@ options: [{

// test multiple short
t.deepEquals({aaA: true, b: true}, parse(['-ba'], {
t.deepEquals({aaA: true, b: true}, await parse(['-ba'], {
parameters: [],

@@ -96,3 +96,3 @@ options: [{

// test multiple, ---, and -
t.deepEquals({aaA: ['bcd', '---', '-']}, parse(['-a', 'bcd', '-a', '---', '-a', '-'], {
t.deepEquals({aaA: ['bcd', '---', '-']}, await parse(['-a', 'bcd', '-a', '---', '-a', '-'], {
parameters: [],

@@ -108,3 +108,3 @@ options: [{

// test empty with equals
t.deepEquals({aaA: ''}, parse(['--aa-a='], {
t.deepEquals({aaA: ''}, await parse(['--aa-a='], {
parameters: [],

@@ -119,3 +119,3 @@ options: [{

// test default
t.deepEquals({aaA: ''}, parse([''], {
t.deepEquals({aaA: ''}, await parse([''], {
parameters: [],

@@ -136,3 +136,3 @@ options: [{

// test default flag
t.deepEquals({aaA: false}, parse([''], {
t.deepEquals({aaA: false}, await parse([''], {
parameters: [],

@@ -146,3 +146,3 @@ options: [{

// test default parameter
t.deepEquals({'0': 'testing', '1': 'yes'}, parse(['testing'], {
t.deepEquals({'0': 'testing', '1': 'yes'}, await parse(['testing'], {
options: [],

@@ -166,3 +166,3 @@ parameters: [{

t.deepEquals({'test0': [1, 2, 3, 4, 5, 6, 7], 'test1': 8, 'test2': 9},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
await parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
options: [],

@@ -186,3 +186,3 @@ parameters: [{

t.deepEquals({'test0': 1, 'test1': ['2', '3', '4', '5', '6', '7', '8'], 'test2': 9},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
await parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
options: [],

@@ -205,3 +205,3 @@ parameters: [{

t.deepEquals({'test0': 1, 'test1': 2, 'test2': [3, 4, 5, 6, 7, 8, 9]},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
await parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
options: [],

@@ -235,3 +235,3 @@ parameters: [{

t.deepEquals({testOption: DEFAULT, testParameter: DEFAULT},
parse([], {
await parse([], {
options: [{

@@ -249,3 +249,3 @@ key: 'test-option',

t.deepEquals({testOption: 'a string', testParameter: 'another string'},
parse(['--test-option', 'a string', 'another string'], {
await parse(['--test-option', 'a string', 'another string'], {
options: [{

@@ -262,3 +262,3 @@ key: 'test-option',

test('test ./parse - with errors', function (t) {
test('test ./parse - with errors', async function (t) {
mockery.enable(mockerySettings)

@@ -286,3 +286,3 @@

// test non-boolean with value
parse(['-a'], {
await parse(['-a'], {
parameters: [],

@@ -298,3 +298,3 @@ options: [{

// test boolean with value
parse(['-a=abc'], {
await parse(['-a=abc'], {
parameters: [],

@@ -307,3 +307,3 @@ options: [{

// test boolean with value
parse(['--aaa=abc'], {
await parse(['--aaa=abc'], {
parameters: [],

@@ -316,9 +316,9 @@ options: [{

// test unknown
parse(['-a'], {options: [], parameters: []})
await parse(['-a'], {options: [], parameters: []})
// test unknown
parse(['--aaa'], {options: [], parameters: []})
await parse(['--aaa'], {options: [], parameters: []})
// test required
parse([''], {
await parse([''], {
parameters: [],

@@ -332,3 +332,3 @@ options: [{

// test required
parse([''], {
await parse([''], {
parameters: [],

@@ -342,3 +342,3 @@ options: [{

// test non multiple multiple
parse(['--aaa=123', '--aaa=456'], {
await parse(['--aaa=123', '--aaa=456'], {
parameters: [],

@@ -352,3 +352,3 @@ options: [{

// test required parameter
parse([], {
await parse([], {
options: [],

@@ -362,3 +362,3 @@ parameters: [{

// test too many arguments
parse(['--', '-a'], {options: [], parameters: []})
await parse(['--', '-a'], {options: [], parameters: []})

@@ -385,3 +385,3 @@ t.equals(globals.process.exitCode, 1)

test('test ./help', function (t) {
test('test ./help', async function (t) {
mockery.enable(mockerySettings)

@@ -406,3 +406,3 @@

help('test-command', '', {
await help('test-command', '', {
parameters: [

@@ -449,3 +449,3 @@ {

help('test-command', 'a test command', {
await help('test-command', 'a test command', {
parameters: [{

@@ -467,3 +467,3 @@ key: 'p0',

help('test-command', 'a test command', {
await help('test-command', 'a test command', {
options: [{

@@ -479,3 +479,3 @@ key: 'aaa',

help('test-command', 'a test command', {options: [], parameters: [], commands: []})
await help('test-command', 'a test command', {options: [], parameters: [], commands: []})

@@ -482,0 +482,0 @@ t.plan(2)

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