Socket
Socket
Sign inDemoInstall

clipanion

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipanion - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

5

lib/advanced/Cli.js

@@ -206,3 +206,6 @@ "use strict";

result += format_1.formatMarkdownish(description, false);
result += [].concat(example.replace(/^/m, ` ${chalk_1.default.bold(prefix)}${this.binaryName} `)).join(`\n`) + `\n`;
result += example
.replace(/^/m, ` ${chalk_1.default.bold(prefix)}`)
.replace(/\$0/m, this.binaryName)
+ `\n`;
}

@@ -209,0 +212,0 @@ }

2

lib/core.d.ts

@@ -45,3 +45,3 @@ export declare const NODE_INITIAL = 0;

}[];
export declare function selectBestState(states: RunState[]): RunState;
export declare function selectBestState(input: string[], states: RunState[]): RunState;
export declare function aggregateHelpStates(states: RunState[]): RunState[];

@@ -48,0 +48,0 @@ declare type Transition = {

@@ -147,3 +147,3 @@ "use strict";

if (nextBranches.length === 0) {
throw new errors.UnknownSyntaxError(branches.filter(({ node }) => {
throw new errors.UnknownSyntaxError(input, branches.filter(({ node }) => {
return node !== exports.NODE_ERRORED;

@@ -155,3 +155,3 @@ }).map(({ state }) => {

if (nextBranches.every(({ node }) => node === exports.NODE_ERRORED)) {
throw new errors.UnknownSyntaxError(nextBranches.map(({ state }) => {
throw new errors.UnknownSyntaxError(input, nextBranches.map(({ state }) => {
return { usage: state.candidateUsage, reason: state.errorMessage };

@@ -171,3 +171,3 @@ }));

}
return selectBestState(branches.map(({ state }) => {
return selectBestState(input, branches.map(({ state }) => {
return state;

@@ -187,3 +187,3 @@ }));

exports.trimSmallerBranches = trimSmallerBranches;
function selectBestState(states) {
function selectBestState(input, states) {
const terminalStates = states.filter(state => {

@@ -218,3 +218,3 @@ return state.selectedIndex !== null;

if (fixedStates.length > 1)
throw new Error();
throw new errors.AmbiguousSyntaxError(input, fixedStates.map(state => state.candidateUsage));
return fixedStates[0];

@@ -470,2 +470,11 @@ }

let lastPathNode = firstNode;
// We allow options to be specified before the path. Note that we
// only do this when there is a path, otherwise there would be
// some redundancy with the options attached later.
if (path.length > 0) {
const optionPathNode = injectNode(machine, makeNode());
registerShortcut(machine, lastPathNode, optionPathNode);
this.registerOptions(machine, optionPathNode);
lastPathNode = optionPathNode;
}
for (let t = 0; t < path.length; ++t) {

@@ -472,0 +481,0 @@ const nextPathNode = injectNode(machine, makeNode());

@@ -11,2 +11,3 @@ export declare type ErrorMeta = {

export declare class UnknownSyntaxError extends Error {
readonly input: string[];
readonly candidates: {

@@ -17,3 +18,3 @@ usage: string;

clipanion: ErrorMeta;
constructor(candidates: {
constructor(input: string[], candidates: {
usage: string;

@@ -24,5 +25,6 @@ reason: string | null;

export declare class AmbiguousSyntaxError extends Error {
readonly input: string[];
readonly usages: string[];
clipanion: ErrorMeta;
constructor(usages: string[]);
constructor(input: string[], usages: string[]);
}

@@ -12,4 +12,5 @@ "use strict";

class UnknownSyntaxError extends Error {
constructor(candidates) {
constructor(input, candidates) {
super();
this.input = input;
this.candidates = candidates;

@@ -27,3 +28,3 @@ this.clipanion = { type: `none` };

const [{ usage }] = this.candidates;
this.message = `Command not found; did you mean:\n\n$ ${usage}`;
this.message = `Command not found; did you mean:\n\n$ ${usage}\n${whileRunning(input)}`;
}

@@ -33,3 +34,3 @@ else {

return `${`${index}.`.padStart(4)} ${usage}`;
}).join(`\n`)}`;
}).join(`\n`)}\n\n${whileRunning(input)}`;
}

@@ -40,4 +41,5 @@ }

class AmbiguousSyntaxError extends Error {
constructor(usages) {
constructor(input, usages) {
super();
this.input = input;
this.usages = usages;

@@ -48,5 +50,14 @@ this.clipanion = { type: `none` };

return `${`${index}.`.padStart(4)} ${usage}`;
}).join(`\n`)}`;
}).join(`\n`)}\n\n${whileRunning(input)}`;
}
}
exports.AmbiguousSyntaxError = AmbiguousSyntaxError;
const whileRunning = (input) => `While running ${input.map(token => {
const json = JSON.stringify(token);
if (token.match(/\s/) || token.length === 0 || json !== `"${token}"`) {
return json;
}
else {
return token;
}
}).join(` `)}`;
{
"name": "clipanion",
"version": "2.1.1",
"version": "2.1.2",
"main": "lib/advanced",

@@ -5,0 +5,0 @@ "license": "MIT",

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