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 22.0.1 to 22.1.0

2

error.js
const chalk = require('chalk')
const { process, console } = require('./src/globals')
module.exports = function (error) {
module.exports = (error) => {
process.exitCode = 1

@@ -6,0 +6,0 @@

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

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

@@ -17,10 +17,10 @@

console.error(chalk.green('Usage:') + ' ' + getUsage(title, {options, parameters}))
console.error(chalk.green('Usage:') + ' ' + getUsage(title, { options, parameters }))
const longestArg = longest(
parameters.map(function (definition) {
parameters.map((definition) => {
return '<' + definition.key + '>'
})
.concat(
options.map(function (definition) {
options.map((definition) => {
return getOptionSignature(definition)

@@ -95,7 +95,7 @@ })

function getUsage (title, {options, parameters}) {
function getUsage (title, { options, parameters }) {
let usage = [title]
if (options && options.length) {
usage = usage.concat(options.map(function (definition) {
usage = usage.concat(options.map((definition) => {
const valPart = definition.type != null

@@ -110,3 +110,3 @@ ? ' <' + definition.key + '>'

if (parameters && parameters.length) {
usage = usage.concat(parameters.map(function (definition) {
usage = usage.concat(parameters.map((definition) => {
return wrapUsage('<' + definition.key + '>', definition)

@@ -119,3 +119,3 @@ }))

function wrapUsage (usage, {required, multiple}) {
function wrapUsage (usage, { required, multiple }) {
const opt = usage.startsWith('-')

@@ -122,0 +122,0 @@

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

} else {
const args = parse(argv, {options: cli.options, parameters: cli.parameters})
const args = parse(argv, { options: cli.options, parameters: cli.parameters })

@@ -32,3 +32,3 @@ try {

if (args.help === true || action == null) {
help(path, description, {options: cli.options, parameters: cli.parameters, commands: cli.commands})
help(path, description, { options: cli.options, parameters: cli.parameters, commands: cli.commands })
} else if (action != null) {

@@ -58,3 +58,3 @@ const result = action(args)

const action = define({option, parameter, command})
const action = define({ option, parameter, command })

@@ -79,3 +79,3 @@ option('help', {

function option (key, definition) {
const current = Object.assign(definition, {key})
const current = Object.assign(definition, { key })

@@ -86,3 +86,3 @@ cli.options.push(current)

function parameter (key, definition) {
const current = Object.assign(definition, {key})
const current = Object.assign(definition, { key })

@@ -89,0 +89,0 @@ cli.parameters.push(current)

{
"name": "sergeant",
"version": "22.0.1",
"version": "22.1.0",
"description": "",

@@ -21,3 +21,3 @@ "main": "main.js",

"proxyquire": "^2.1.0",
"standard": "^11.0.1",
"standard": "^12.0.1",
"tape": "^4.9.1"

@@ -24,0 +24,0 @@ },

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

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

@@ -11,4 +11,4 @@ argv = argv.slice(0)

options = options.reduce(function (options, definition) {
definition = Object.assign({}, definition, {property: camelCaseFromDash(definition.key)})
options = options.reduce((options, definition) => {
definition = Object.assign({}, definition, { property: camelCaseFromDash(definition.key) })

@@ -18,3 +18,3 @@ options.push(definition)

if (definition.alias) {
options.push(Object.assign({}, definition, {key: definition.alias, alias: true}))
options.push(Object.assign({}, definition, { key: definition.alias, alias: true }))
}

@@ -25,4 +25,4 @@

parameters = parameters.reduce(function (parameters, definition) {
definition = Object.assign({}, definition, {property: camelCaseFromDash(definition.key)})
parameters = parameters.reduce((parameters, definition) => {
definition = Object.assign({}, definition, { property: camelCaseFromDash(definition.key) })

@@ -43,3 +43,3 @@ parameters.push(definition)

argv = argv.reduce(function (argv, arg) {
argv = argv.reduce((argv, arg) => {
if (arg !== '-' && arg.startsWith('-') && !arg.startsWith('--')) {

@@ -128,3 +128,3 @@ if (arg.indexOf('=') > -1) {

argv = argv.reduce(function (argv, arg, i) {
argv = argv.reduce((argv, arg, i) => {
if (!toBeDeleted.includes(i)) {

@@ -131,0 +131,0 @@ argv.push(arg)

@@ -11,3 +11,3 @@ # sergeant

command('hello', function ({option, parameter, command}) {
command('hello', ({option, parameter, command}) => {
parameter('name', {

@@ -23,3 +23,3 @@ description: 'the name',

command('world', function ({option}) {
command('world', ({option}) => {
option('loud', {

@@ -30,3 +30,3 @@ description: 'say it loud',,

return function (args) {
return (args) => {
say('world', args.loud)

@@ -36,3 +36,3 @@ }

return function (args) {
return (args) => {
assert.notEqual(args.name, 'world', 'use hello world')

@@ -39,0 +39,0 @@

@@ -8,3 +8,3 @@ module.exports = { addDashes, longest, spaces, camelCaseFromDash }

function longest (arr) {
return arr.reduce(function (longest, item) {
return arr.reduce((longest, item) => {
return item.length > longest ? item.length : longest

@@ -11,0 +11,0 @@ }, 0)

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

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

@@ -12,3 +12,3 @@

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// test multiple param beginning
t.deepEquals({'test0': [1, 2, 3, 4, 5, 6, 7], 'test1': 8, 'test2': 9},
t.deepEquals({ 'test0': [1, 2, 3, 4, 5, 6, 7], 'test1': 8, 'test2': 9 },
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {

@@ -179,3 +179,3 @@ options: [],

// test multiple param middle. No type
t.deepEquals({'test0': 1, 'test1': ['2', '3', '4', '5', '6', '7', '8'], 'test2': 9},
t.deepEquals({ 'test0': 1, 'test1': ['2', '3', '4', '5', '6', '7', '8'], 'test2': 9 },
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {

@@ -198,3 +198,3 @@ options: [],

// test multiple param end
t.deepEquals({'test0': 1, 'test1': 2, 'test2': [3, 4, 5, 6, 7, 8, 9]},
t.deepEquals({ 'test0': 1, 'test1': 2, 'test2': [3, 4, 5, 6, 7, 8, 9] },
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {

@@ -228,3 +228,3 @@ options: [],

// test default with type
t.deepEquals({testOption: DEFAULT, testParameter: DEFAULT},
t.deepEquals({ testOption: DEFAULT, testParameter: DEFAULT },
parse([], {

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

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

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

test('test ./parse - with errors', function (t) {
test('test ./parse - with errors', (t) => {
const messages = []

@@ -305,6 +305,6 @@

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

@@ -348,3 +348,3 @@ // test required

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

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

test('test ./help', function (t) {
test('test ./help', (t) => {
const messages = []

@@ -486,3 +486,3 @@

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

@@ -547,3 +547,3 @@ t.plan(2)

test('test ./error', function (t) {
test('test ./error', (t) => {
const messages = []

@@ -592,3 +592,3 @@

test('test ./command - no help. no errors', function (t) {
test('test ./command - no help. no errors', (t) => {
const command = proxyquire('./main', {

@@ -624,3 +624,3 @@ './parse': mockedParse

const testCommand = command('test-command', function ({option, parameter}) {
const testCommand = command('test-command', ({ option, parameter }) => {
parameter('aaa', {

@@ -634,3 +634,3 @@ testing: true

return function () {
return () => {
t.ok(true)

@@ -643,3 +643,3 @@ }

test('test ./command - help', function (t) {
test('test ./command - help', (t) => {
const command = proxyquire('./main', {

@@ -681,3 +681,3 @@ './parse': mockedParse,

const testCommand = command('test-command', function ({parameter, option}) {
const testCommand = command('test-command', ({ parameter, option }) => {
parameter('aaa', {

@@ -690,3 +690,4 @@ testing: true

})
return function () {}
return () => {}
})

@@ -697,3 +698,3 @@

test('test ./command - thrown error', function (t) {
test('test ./command - thrown error', (t) => {
const command = proxyquire('./main', {

@@ -716,6 +717,4 @@ './parse': mockedParse,

const testCommand = command('test-command', function () {
return function () {
throw ourError
}
const testCommand = command('test-command', () => () => {
throw ourError
})

@@ -726,3 +725,3 @@

test('test ./command - rejected promise', function (t) {
test('test ./command - rejected promise', (t) => {
const command = proxyquire('./main', {

@@ -745,6 +744,4 @@ './parse': mockedParse,

const testCommand = command('test-command', function () {
return function () {
return Promise.reject(ourError)
}
const testCommand = command('test-command', () => async () => {
throw ourError
})

@@ -755,5 +752,5 @@

test('test ./command - sub commands', function (t) {
test('test ./command - sub commands', (t) => {
const command = proxyquire('./main', {
'./parse': function () { return {} }
'./parse' () { return {} }
})

@@ -763,16 +760,12 @@

const testCommand = command('test-command', function ({option, parameter, command}) {
command('sub-command', 'a sub command', function () {
return function () {
t.ok(true)
}
const testCommand = command('test-command', ({ option, parameter, command }) => {
command('sub-command', 'a sub command', () => () => {
t.ok(true)
})
command('sub-command-b', function () {
return function () {
t.ok(true)
}
command('sub-command-b', () => () => {
t.ok(true)
})
return function () {
return () => {
t.ok(false)

@@ -779,0 +772,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