aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/concurrently/dist/src/command-parser
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/concurrently/dist/src/command-parser
initial commit: scaffolding
Diffstat (limited to 'node_modules/concurrently/dist/src/command-parser')
-rw-r--r--node_modules/concurrently/dist/src/command-parser/command-parser.d.ts19
-rw-r--r--node_modules/concurrently/dist/src/command-parser/command-parser.js2
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-arguments.d.ts17
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-arguments.js38
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.d.ts8
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.js20
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.d.ts13
-rw-r--r--node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.js68
-rw-r--r--node_modules/concurrently/dist/src/command-parser/strip-quotes.d.ts15
-rw-r--r--node_modules/concurrently/dist/src/command-parser/strip-quotes.js17
10 files changed, 217 insertions, 0 deletions
diff --git a/node_modules/concurrently/dist/src/command-parser/command-parser.d.ts b/node_modules/concurrently/dist/src/command-parser/command-parser.d.ts
new file mode 100644
index 0000000..37ab795
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/command-parser.d.ts
@@ -0,0 +1,19 @@
+import { CommandInfo } from '../command';
+/**
+ * A command parser encapsulates a specific logic for mapping `CommandInfo` objects
+ * into another `CommandInfo`.
+ *
+ * A prime example is turning an abstract `npm:foo` into `npm run foo`, but it could also turn
+ * the prefix color of a command brighter, or maybe even prefixing each command with `time(1)`.
+ */
+export interface CommandParser {
+ /**
+ * Parses `commandInfo` and returns one or more `CommandInfo`s.
+ *
+ * Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to
+ * run given the original input.
+ * An example of this is when the command contains a wildcard and it must be expanded into all
+ * viable options so that the consumer can decide which ones to run.
+ */
+ parse(commandInfo: CommandInfo): CommandInfo | CommandInfo[];
+}
diff --git a/node_modules/concurrently/dist/src/command-parser/command-parser.js b/node_modules/concurrently/dist/src/command-parser/command-parser.js
new file mode 100644
index 0000000..c8ad2e5
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/command-parser.js
@@ -0,0 +1,2 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-arguments.d.ts b/node_modules/concurrently/dist/src/command-parser/expand-arguments.d.ts
new file mode 100644
index 0000000..c88e731
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-arguments.d.ts
@@ -0,0 +1,17 @@
+import { CommandInfo } from '../command';
+import { CommandParser } from './command-parser';
+/**
+ * Replace placeholders with additional arguments.
+ */
+export declare class ExpandArguments implements CommandParser {
+ private readonly additionalArguments;
+ constructor(additionalArguments: string[]);
+ parse(commandInfo: CommandInfo): {
+ command: string;
+ name: string;
+ env?: Record<string, unknown> | undefined;
+ cwd?: string | undefined;
+ prefixColor?: string | undefined;
+ raw?: boolean | undefined;
+ };
+}
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-arguments.js b/node_modules/concurrently/dist/src/command-parser/expand-arguments.js
new file mode 100644
index 0000000..42c087c
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-arguments.js
@@ -0,0 +1,38 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.ExpandArguments = void 0;
+const shell_quote_1 = require("shell-quote");
+/**
+ * Replace placeholders with additional arguments.
+ */
+class ExpandArguments {
+ constructor(additionalArguments) {
+ this.additionalArguments = additionalArguments;
+ }
+ parse(commandInfo) {
+ const command = commandInfo.command.replace(/\\?\{([@*]|[1-9][0-9]*)\}/g, (match, placeholderTarget) => {
+ // Don't replace the placeholder if it is escaped by a backslash.
+ if (match.startsWith('\\')) {
+ return match.slice(1);
+ }
+ // Replace numeric placeholder if value exists in additional arguments.
+ if (!isNaN(placeholderTarget) &&
+ placeholderTarget <= this.additionalArguments.length) {
+ return (0, shell_quote_1.quote)([this.additionalArguments[placeholderTarget - 1]]);
+ }
+ // Replace all arguments placeholder.
+ if (placeholderTarget === '@') {
+ return (0, shell_quote_1.quote)(this.additionalArguments);
+ }
+ // Replace combined arguments placeholder.
+ if (placeholderTarget === '*') {
+ return (0, shell_quote_1.quote)([this.additionalArguments.join(' ')]);
+ }
+ // Replace placeholder with empty string
+ // if value doesn't exist in additional arguments.
+ return '';
+ });
+ return { ...commandInfo, command };
+ }
+}
+exports.ExpandArguments = ExpandArguments;
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.d.ts b/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.d.ts
new file mode 100644
index 0000000..636018a
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.d.ts
@@ -0,0 +1,8 @@
+import { CommandInfo } from '../command';
+import { CommandParser } from './command-parser';
+/**
+ * Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
+ */
+export declare class ExpandNpmShortcut implements CommandParser {
+ parse(commandInfo: CommandInfo): CommandInfo;
+}
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.js b/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.js
new file mode 100644
index 0000000..9a62362
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-npm-shortcut.js
@@ -0,0 +1,20 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.ExpandNpmShortcut = void 0;
+/**
+ * Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
+ */
+class ExpandNpmShortcut {
+ parse(commandInfo) {
+ const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm|bun):(\S+)(.*)/) || [];
+ if (!cmdName) {
+ return commandInfo;
+ }
+ return {
+ ...commandInfo,
+ name: commandInfo.name || cmdName,
+ command: `${npmCmd} run ${cmdName}${args}`,
+ };
+ }
+}
+exports.ExpandNpmShortcut = ExpandNpmShortcut;
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.d.ts b/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.d.ts
new file mode 100644
index 0000000..cc5f413
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.d.ts
@@ -0,0 +1,13 @@
+import { CommandInfo } from '../command';
+import { CommandParser } from './command-parser';
+/**
+ * Finds wildcards in npm/yarn/pnpm/bun run commands and replaces them with all matching scripts in the
+ * `package.json` file of the current directory.
+ */
+export declare class ExpandNpmWildcard implements CommandParser {
+ private readonly readPackage;
+ static readPackage(): any;
+ private scripts?;
+ constructor(readPackage?: typeof ExpandNpmWildcard.readPackage);
+ parse(commandInfo: CommandInfo): CommandInfo | CommandInfo[];
+}
diff --git a/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.js b/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.js
new file mode 100644
index 0000000..0109207
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/expand-npm-wildcard.js
@@ -0,0 +1,68 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.ExpandNpmWildcard = void 0;
+const fs_1 = __importDefault(require("fs"));
+const lodash_1 = __importDefault(require("lodash"));
+const OMISSION = /\(!([^)]+)\)/;
+/**
+ * Finds wildcards in npm/yarn/pnpm/bun run commands and replaces them with all matching scripts in the
+ * `package.json` file of the current directory.
+ */
+class ExpandNpmWildcard {
+ static readPackage() {
+ try {
+ const json = fs_1.default.readFileSync('package.json', { encoding: 'utf-8' });
+ return JSON.parse(json);
+ }
+ catch (e) {
+ return {};
+ }
+ }
+ constructor(readPackage = ExpandNpmWildcard.readPackage) {
+ this.readPackage = readPackage;
+ }
+ parse(commandInfo) {
+ const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm|bun) run (\S+)([^&]*)/) || [];
+ const wildcardPosition = (cmdName || '').indexOf('*');
+ // If the regex didn't match an npm script, or it has no wildcard,
+ // then we have nothing to do here
+ if (!cmdName || wildcardPosition === -1) {
+ return commandInfo;
+ }
+ if (!this.scripts) {
+ this.scripts = Object.keys(this.readPackage().scripts || {});
+ }
+ const omissionRegex = cmdName.match(OMISSION);
+ const cmdNameSansOmission = cmdName.replace(OMISSION, '');
+ const preWildcard = lodash_1.default.escapeRegExp(cmdNameSansOmission.slice(0, wildcardPosition));
+ const postWildcard = lodash_1.default.escapeRegExp(cmdNameSansOmission.slice(wildcardPosition + 1));
+ const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
+ // If 'commandInfo.name' doesn't match 'cmdName', this means a custom name
+ // has been specified and thus becomes the prefix (as described in the README).
+ const prefix = commandInfo.name !== cmdName ? commandInfo.name : '';
+ return this.scripts
+ .map((script) => {
+ const match = script.match(wildcardRegex);
+ if (omissionRegex) {
+ const toOmit = script.match(new RegExp(omissionRegex[1]));
+ if (toOmit) {
+ return;
+ }
+ }
+ if (match) {
+ return {
+ ...commandInfo,
+ command: `${npmCmd} run ${script}${args}`,
+ // Will use an empty command name if no prefix has been specified and
+ // the wildcard match is empty, e.g. if `npm:watch-*` matches `npm run watch-`.
+ name: prefix + match[1],
+ };
+ }
+ })
+ .filter((commandInfo) => !!commandInfo);
+ }
+}
+exports.ExpandNpmWildcard = ExpandNpmWildcard;
diff --git a/node_modules/concurrently/dist/src/command-parser/strip-quotes.d.ts b/node_modules/concurrently/dist/src/command-parser/strip-quotes.d.ts
new file mode 100644
index 0000000..1a21b79
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/strip-quotes.d.ts
@@ -0,0 +1,15 @@
+import { CommandInfo } from '../command';
+import { CommandParser } from './command-parser';
+/**
+ * Strips quotes around commands so that they can run on the current shell.
+ */
+export declare class StripQuotes implements CommandParser {
+ parse(commandInfo: CommandInfo): {
+ command: string;
+ name: string;
+ env?: Record<string, unknown> | undefined;
+ cwd?: string | undefined;
+ prefixColor?: string | undefined;
+ raw?: boolean | undefined;
+ };
+}
diff --git a/node_modules/concurrently/dist/src/command-parser/strip-quotes.js b/node_modules/concurrently/dist/src/command-parser/strip-quotes.js
new file mode 100644
index 0000000..971a524
--- /dev/null
+++ b/node_modules/concurrently/dist/src/command-parser/strip-quotes.js
@@ -0,0 +1,17 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.StripQuotes = void 0;
+/**
+ * Strips quotes around commands so that they can run on the current shell.
+ */
+class StripQuotes {
+ parse(commandInfo) {
+ let { command } = commandInfo;
+ // Removes the quotes surrounding a command.
+ if (/^"(.+?)"$/.test(command) || /^'(.+?)'$/.test(command)) {
+ command = command.slice(1, command.length - 1);
+ }
+ return { ...commandInfo, command };
+ }
+}
+exports.StripQuotes = StripQuotes;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage