Bump @ava/typescript from 3.0.1 to 4.0.0 (#1576)

* Bump @ava/typescript from 3.0.1 to 4.0.0

Bumps [@ava/typescript](https://github.com/avajs/typescript) from 3.0.1 to 4.0.0.
- [Release notes](https://github.com/avajs/typescript/releases)
- [Commits](https://github.com/avajs/typescript/compare/v3.0.1...v4.0.0)

---
updated-dependencies:
- dependency-name: "@ava/typescript"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update checked-in dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions@github.com>
This commit is contained in:
dependabot[bot] 2023-03-13 14:10:40 -07:00 committed by GitHub
parent ec298233c1
commit 19f00dc212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 2374 additions and 1754 deletions

140
node_modules/.package-lock.json generated vendored
View file

@ -142,16 +142,16 @@
} }
}, },
"node_modules/@ava/typescript": { "node_modules/@ava/typescript": {
"version": "3.0.1", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-3.0.1.tgz", "resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-4.0.0.tgz",
"integrity": "sha512-/JXIUuKsvkaneaiA9ckk3ksFTqvu0mDNlChASrTe2BnDsvMbhQdPWyqQjJ9WRJWVhhs5TWn1/0Pp1G6Rv8Syrw==", "integrity": "sha512-QFIPeqkEbdvn7Pob0wVeYpeZD0eXd8nDYdCl+knJVaIJrHdF2fXa58vFaig26cmYwnsEN0KRNTYJKbqW1B0lfg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"escape-string-regexp": "^5.0.0", "escape-string-regexp": "^5.0.0",
"execa": "^5.1.1" "execa": "^7.1.0"
}, },
"engines": { "engines": {
"node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17" "node": ">=14.19 <15 || >=16.15 <17 || >=18"
} }
}, },
"node_modules/@ava/typescript/node_modules/escape-string-regexp": { "node_modules/@ava/typescript/node_modules/escape-string-regexp": {
@ -3043,40 +3043,28 @@
} }
}, },
"node_modules/execa": { "node_modules/execa": {
"version": "5.1.1", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", "resolved": "https://registry.npmjs.org/execa/-/execa-7.1.0.tgz",
"integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", "integrity": "sha512-T6nIJO3LHxUZ6ahVRaxXz9WLEruXLqdcluA+UuTptXmLM7nDAn9lx9IfkxPyzEL21583qSt4RmL44pO71EHaJQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"get-stream": "^6.0.0", "get-stream": "^6.0.1",
"human-signals": "^2.1.0", "human-signals": "^4.3.0",
"is-stream": "^2.0.0", "is-stream": "^3.0.0",
"merge-stream": "^2.0.0", "merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1", "npm-run-path": "^5.1.0",
"onetime": "^5.1.2", "onetime": "^6.0.0",
"signal-exit": "^3.0.3", "signal-exit": "^3.0.7",
"strip-final-newline": "^2.0.0" "strip-final-newline": "^3.0.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": "^14.18.0 || ^16.14.0 || >=18.0.0"
}, },
"funding": { "funding": {
"url": "https://github.com/sindresorhus/execa?sponsor=1" "url": "https://github.com/sindresorhus/execa?sponsor=1"
} }
}, },
"node_modules/execa/node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/fast-deep-equal": { "node_modules/fast-deep-equal": {
"version": "3.1.3", "version": "3.1.3",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
@ -3328,6 +3316,18 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/get-symbol-description": { "node_modules/get-symbol-description": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
@ -3560,12 +3560,12 @@
} }
}, },
"node_modules/human-signals": { "node_modules/human-signals": {
"version": "2.1.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.0.tgz",
"integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "integrity": "sha512-zyzVyMjpGBX2+6cDVZeFPCdtOtdsxOeseRhB9tkQ6xXmGUNrcnBzdEKPy3VPNYz+4gy1oukVOXcrJCunSyc6QQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=10.17.0" "node": ">=14.18.0"
} }
}, },
"node_modules/ignore": { "node_modules/ignore": {
@ -3939,12 +3939,12 @@
} }
}, },
"node_modules/is-stream": { "node_modules/is-stream": {
"version": "2.0.1", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
@ -4341,18 +4341,6 @@
"url": "https://github.com/sindresorhus/mem?sponsor=1" "url": "https://github.com/sindresorhus/mem?sponsor=1"
} }
}, },
"node_modules/mem/node_modules/mimic-fn": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/merge-stream": { "node_modules/merge-stream": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@ -4399,11 +4387,15 @@
} }
}, },
"node_modules/mimic-fn": { "node_modules/mimic-fn": {
"version": "2.1.0", "version": "4.0.0",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
@ -4540,15 +4532,30 @@
} }
}, },
"node_modules/npm-run-path": { "node_modules/npm-run-path": {
"version": "4.0.1", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz",
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"path-key": "^3.0.0" "path-key": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/npm-run-path/node_modules/path-key": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
"integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/object-inspect": { "node_modules/object-inspect": {
@ -4659,15 +4666,15 @@
} }
}, },
"node_modules/onetime": { "node_modules/onetime": {
"version": "5.1.2", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"mimic-fn": "^2.1.0" "mimic-fn": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">=6" "node": ">=12"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
@ -5504,12 +5511,15 @@
} }
}, },
"node_modules/strip-final-newline": { "node_modules/strip-final-newline": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/strip-json-comments": { "node_modules/strip-json-comments": {

View file

@ -1,21 +1,11 @@
# @ava/typescript # @ava/typescript
Adds [TypeScript](https://www.typescriptlang.org/) support to [AVA 4](https://avajs.dev). Adds [TypeScript](https://www.typescriptlang.org/) support to [AVA](https://avajs.dev).
This is designed to work for projects that precompile TypeScript. It allows AVA to load the compiled JavaScript, while configuring AVA to treat the TypeScript files as test files. This is designed to work for projects that precompile TypeScript. It allows AVA to load the compiled JavaScript, while configuring AVA to treat the TypeScript files as test files.
In other words, say you have a test file at `src/test.ts`. You've configured TypeScript to output to `build/`. Using `@ava/typescript` you can run the test using `npx ava src/test.ts`. In other words, say you have a test file at `src/test.ts`. You've configured TypeScript to output to `build/`. Using `@ava/typescript` you can run the test using `npx ava src/test.ts`.
## For AVA 3 users
Use version 2:
```console
npm install --save-dev @ava/typescript@2
```
Note that v2 does not support ES modules. This requires v3 and AVA 4.
## Enabling TypeScript support ## Enabling TypeScript support
Add this package to your project: Add this package to your project:
@ -47,7 +37,7 @@ You can enable compilation via the `compile` property. If `false`, AVA will assu
Output files are expected to have the `.js` extension. Output files are expected to have the `.js` extension.
AVA searches your entire project for `*.js`, `*.cjs`, `*.mjs` and `*.ts` files (or other extensions you've configured). It will ignore such files found in the `rewritePaths` targets (e.g. `build/`). If you use more specific paths, for instance `build/main/`, you may need to change AVA's `files` configuration to ignore other directories. AVA searches your entire project for `*.js`, `*.cjs`, `*.mjs`, `*.ts`, `*.cts` and `*.mts` files (or other extensions you've configured). It will ignore such files found in the `rewritePaths` targets (e.g. `build/`). If you use more specific paths, for instance `build/main/`, you may need to change AVA's `files` configuration to ignore other directories.
## ES Modules ## ES Modules
@ -75,6 +65,8 @@ You can configure AVA to recognize additional file extensions. To add (partial
} }
``` ```
If you use the [`allowJs` TypeScript option](https://www.typescriptlang.org/tsconfig/allowJs.html) you'll have to specify the `js`, `cjs` and `mjs` extensions for them to be rewritten.
See also AVA's [`extensions` option](https://github.com/avajs/ava/blob/master/docs/06-configuration.md#options). See also AVA's [`extensions` option](https://github.com/avajs/ava/blob/master/docs/06-configuration.md#options).
† Note that the [*preserve* mode for JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) is not (yet) supported. † Note that the [*preserve* mode for JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) is not (yet) supported.

View file

@ -2,7 +2,7 @@ import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import {pathToFileURL} from 'node:url'; import {pathToFileURL} from 'node:url';
import escapeStringRegexp from 'escape-string-regexp'; import escapeStringRegexp from 'escape-string-regexp';
import execa from 'execa'; import {execa} from 'execa';
const pkg = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url))); const pkg = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url)));
const help = `See https://github.com/avajs/typescript/blob/v${pkg.version}/README.md`; const help = `See https://github.com/avajs/typescript/blob/v${pkg.version}/README.md`;
@ -83,7 +83,7 @@ export default function typescriptProvider({negotiateProtocol}) {
validate(config, configProperties); validate(config, configProperties);
const { const {
extensions = ['ts'], extensions = ['ts', 'cts', 'mts'],
rewritePaths: relativeRewritePaths, rewritePaths: relativeRewritePaths,
compile, compile,
} = config; } = config;
@ -118,7 +118,7 @@ export default function typescriptProvider({negotiateProtocol}) {
return rewritePaths.some(([from]) => filePath.startsWith(from)); return rewritePaths.some(([from]) => filePath.startsWith(from));
}, },
resolveTestFile(testfile) { resolveTestFile(testfile) { // Used under AVA 3.2 protocol by legacy watcher implementation.
if (!testFileExtension.test(testfile)) { if (!testFileExtension.test(testfile)) {
return testfile; return testfile;
} }
@ -129,8 +129,14 @@ export default function typescriptProvider({negotiateProtocol}) {
} }
const [from, to] = rewrite; const [from, to] = rewrite;
// TODO: Support JSX preserve mode — https://www.typescriptlang.org/docs/handbook/jsx.html let newExtension = '.js';
return `${to}${testfile.slice(from.length)}`.replace(testFileExtension, '.js'); if (testfile.endsWith('.cts')) {
newExtension = '.cjs';
} else if (testfile.endsWith('.mts')) {
newExtension = '.mjs';
}
return `${to}${testfile.slice(from.length)}`.replace(testFileExtension, newExtension);
}, },
updateGlobs({filePatterns, ignoredByWatcherPatterns}) { updateGlobs({filePatterns, ignoredByWatcherPatterns}) {
@ -142,7 +148,11 @@ export default function typescriptProvider({negotiateProtocol}) {
], ],
ignoredByWatcherPatterns: [ ignoredByWatcherPatterns: [
...ignoredByWatcherPatterns, ...ignoredByWatcherPatterns,
...Object.values(relativeRewritePaths).map(to => `${to}**/*.js.map`), ...Object.values(relativeRewritePaths).flatMap(to => [
`${to}**/*.js.map`,
`${to}**/*.cjs.map`,
`${to}**/*.mjs.map`,
]),
], ],
}; };
}, },
@ -150,7 +160,7 @@ export default function typescriptProvider({negotiateProtocol}) {
}, },
worker({extensionsToLoadAsModules, state: {extensions, rewritePaths}}) { worker({extensionsToLoadAsModules, state: {extensions, rewritePaths}}) {
const useImport = extensionsToLoadAsModules.includes('js'); const importJs = extensionsToLoadAsModules.includes('js');
const testFileExtension = new RegExp(`\\.(${extensions.map(ext => escapeStringRegexp(ext)).join('|')})$`); const testFileExtension = new RegExp(`\\.(${extensions.map(ext => escapeStringRegexp(ext)).join('|')})$`);
return { return {
@ -160,9 +170,19 @@ export default function typescriptProvider({negotiateProtocol}) {
async load(ref, {requireFn}) { async load(ref, {requireFn}) {
const [from, to] = rewritePaths.find(([from]) => ref.startsWith(from)); const [from, to] = rewritePaths.find(([from]) => ref.startsWith(from));
// TODO: Support JSX preserve mode — https://www.typescriptlang.org/docs/handbook/jsx.html let rewritten = `${to}${ref.slice(from.length)}`;
const rewritten = `${to}${ref.slice(from.length)}`.replace(testFileExtension, '.js'); let useImport = true;
return useImport ? import(pathToFileURL(rewritten)) : requireFn(rewritten); // eslint-disable-line node/no-unsupported-features/es-syntax if (ref.endsWith('.cts')) {
rewritten = rewritten.replace(/\.cts$/, '.cjs');
useImport = false;
} else if (ref.endsWith('.mts')) {
rewritten = rewritten.replace(/\.mts$/, '.mjs');
} else {
rewritten = rewritten.replace(testFileExtension, '.js');
useImport = importJs;
}
return useImport ? import(pathToFileURL(rewritten)) : requireFn(rewritten);
}, },
}; };
}, },

View file

@ -1,9 +1,9 @@
{ {
"name": "@ava/typescript", "name": "@ava/typescript",
"version": "3.0.1", "version": "4.0.0",
"description": "TypeScript provider for AVA", "description": "TypeScript provider for AVA",
"engines": { "engines": {
"node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17" "node": ">=14.19 <15 || >=16.15 <17 || >=18"
}, },
"files": [ "files": [
"index.js" "index.js"
@ -24,14 +24,14 @@
}, },
"dependencies": { "dependencies": {
"escape-string-regexp": "^5.0.0", "escape-string-regexp": "^5.0.0",
"execa": "^5.1.1" "execa": "^7.1.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "4.0.0-rc.1", "ava": "^5.2.0",
"c8": "^7.10.0", "c8": "^7.13.0",
"del": "^6.0.0", "del": "^7.0.0",
"typescript": "^4.4.4", "typescript": "^4.9.5",
"xo": "^0.46.3" "xo": "^0.53.1"
}, },
"c8": { "c8": {
"reporter": [ "reporter": [
@ -52,7 +52,8 @@
}, },
"xo": { "xo": {
"ignores": [ "ignores": [
"test/broken-fixtures" "test/broken-fixtures",
"test/fixtures/**/compiled/**"
] ]
} }
} }

1436
node_modules/execa/index.d.ts generated vendored

File diff suppressed because it is too large Load diff

119
node_modules/execa/index.js generated vendored
View file

@ -1,16 +1,19 @@
'use strict'; import {Buffer} from 'node:buffer';
const path = require('path'); import path from 'node:path';
const childProcess = require('child_process'); import childProcess from 'node:child_process';
const crossSpawn = require('cross-spawn'); import process from 'node:process';
const stripFinalNewline = require('strip-final-newline'); import crossSpawn from 'cross-spawn';
const npmRunPath = require('npm-run-path'); import stripFinalNewline from 'strip-final-newline';
const onetime = require('onetime'); import {npmRunPathEnv} from 'npm-run-path';
const makeError = require('./lib/error'); import onetime from 'onetime';
const normalizeStdio = require('./lib/stdio'); import {makeError} from './lib/error.js';
const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = require('./lib/kill'); import {normalizeStdio, normalizeStdioNode} from './lib/stdio.js';
const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = require('./lib/stream'); import {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} from './lib/kill.js';
const {mergePromise, getSpawnedPromise} = require('./lib/promise'); import {addPipeMethods} from './lib/pipe.js';
const {joinCommand, parseCommand, getEscapedCommand} = require('./lib/command'); import {handleInput, getSpawnedResult, makeAllStream, handleInputSync} from './lib/stream.js';
import {mergePromise, getSpawnedPromise} from './lib/promise.js';
import {joinCommand, parseCommand, parseTemplates, getEscapedCommand} from './lib/command.js';
import {logCommand, verboseDefault} from './lib/verbose.js';
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
@ -18,7 +21,7 @@ const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) =>
const env = extendEnv ? {...process.env, ...envOption} : envOption; const env = extendEnv ? {...process.env, ...envOption} : envOption;
if (preferLocal) { if (preferLocal) {
return npmRunPath.env({env, cwd: localDir, execPath}); return npmRunPathEnv({env, cwd: localDir, execPath});
} }
return env; return env;
@ -43,7 +46,8 @@ const handleArguments = (file, args, options = {}) => {
cleanup: true, cleanup: true,
all: false, all: false,
windowsHide: true, windowsHide: true,
...options verbose: verboseDefault,
...options,
}; };
options.env = getEnv(options); options.env = getEnv(options);
@ -60,7 +64,7 @@ const handleArguments = (file, args, options = {}) => {
const handleOutput = (options, value, error) => { const handleOutput = (options, value, error) => {
if (typeof value !== 'string' && !Buffer.isBuffer(value)) { if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
// When `execa.sync()` errors, we normalize it to '' to mimic `execa()` // When `execaSync()` errors, we normalize it to '' to mimic `execa()`
return error === undefined ? undefined : ''; return error === undefined ? undefined : '';
} }
@ -71,10 +75,11 @@ const handleOutput = (options, value, error) => {
return value; return value;
}; };
const execa = (file, args, options) => { export function execa(file, args, options) {
const parsed = handleArguments(file, args, options); const parsed = handleArguments(file, args, options);
const command = joinCommand(file, args); const command = joinCommand(file, args);
const escapedCommand = getEscapedCommand(file, args); const escapedCommand = getEscapedCommand(file, args);
logCommand(escapedCommand, parsed.options);
validateTimeout(parsed.options); validateTimeout(parsed.options);
@ -94,9 +99,10 @@ const execa = (file, args, options) => {
parsed, parsed,
timedOut: false, timedOut: false,
isCanceled: false, isCanceled: false,
killed: false killed: false,
})); }));
return mergePromise(dummySpawned, errorPromise); mergePromise(dummySpawned, errorPromise);
return dummySpawned;
} }
const spawnedPromise = getSpawnedPromise(spawned); const spawnedPromise = getSpawnedPromise(spawned);
@ -126,8 +132,8 @@ const execa = (file, args, options) => {
escapedCommand, escapedCommand,
parsed, parsed,
timedOut, timedOut,
isCanceled: context.isCanceled, isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
killed: spawned.killed killed: spawned.killed,
}); });
if (!parsed.options.reject) { if (!parsed.options.reject) {
@ -147,31 +153,32 @@ const execa = (file, args, options) => {
failed: false, failed: false,
timedOut: false, timedOut: false,
isCanceled: false, isCanceled: false,
killed: false killed: false,
}; };
}; };
const handlePromiseOnce = onetime(handlePromise); const handlePromiseOnce = onetime(handlePromise);
handleInput(spawned, parsed.options.input); handleInput(spawned, parsed.options);
spawned.all = makeAllStream(spawned, parsed.options); spawned.all = makeAllStream(spawned, parsed.options);
return mergePromise(spawned, handlePromiseOnce); addPipeMethods(spawned);
}; mergePromise(spawned, handlePromiseOnce);
return spawned;
}
module.exports = execa; export function execaSync(file, args, options) {
module.exports.sync = (file, args, options) => {
const parsed = handleArguments(file, args, options); const parsed = handleArguments(file, args, options);
const command = joinCommand(file, args); const command = joinCommand(file, args);
const escapedCommand = getEscapedCommand(file, args); const escapedCommand = getEscapedCommand(file, args);
logCommand(escapedCommand, parsed.options);
validateInputSync(parsed.options); const input = handleInputSync(parsed.options);
let result; let result;
try { try {
result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options); result = childProcess.spawnSync(parsed.file, parsed.args, {...parsed.options, input});
} catch (error) { } catch (error) {
throw makeError({ throw makeError({
error, error,
@ -183,7 +190,7 @@ module.exports.sync = (file, args, options) => {
parsed, parsed,
timedOut: false, timedOut: false,
isCanceled: false, isCanceled: false,
killed: false killed: false,
}); });
} }
@ -202,7 +209,7 @@ module.exports.sync = (file, args, options) => {
parsed, parsed,
timedOut: result.error && result.error.code === 'ETIMEDOUT', timedOut: result.error && result.error.code === 'ETIMEDOUT',
isCanceled: false, isCanceled: false,
killed: result.signal !== null killed: result.signal !== null,
}); });
if (!parsed.options.reject) { if (!parsed.options.reject) {
@ -221,32 +228,52 @@ module.exports.sync = (file, args, options) => {
failed: false, failed: false,
timedOut: false, timedOut: false,
isCanceled: false, isCanceled: false,
killed: false killed: false,
}; };
}; }
module.exports.command = (command, options) => { function create$(options) {
function $(templatesOrOptions, ...expressions) {
if (Array.isArray(templatesOrOptions)) {
const [file, ...args] = parseTemplates(templatesOrOptions, expressions);
return execa(file, args, options);
}
return create$({...options, ...templatesOrOptions});
}
$.sync = (templates, ...expressions) => {
const [file, ...args] = parseTemplates(templates, expressions);
return execaSync(file, args, options);
};
return $;
}
export const $ = create$({preferLocal: true});
export function execaCommand(command, options) {
const [file, ...args] = parseCommand(command); const [file, ...args] = parseCommand(command);
return execa(file, args, options); return execa(file, args, options);
}; }
module.exports.commandSync = (command, options) => { export function execaCommandSync(command, options) {
const [file, ...args] = parseCommand(command); const [file, ...args] = parseCommand(command);
return execa.sync(file, args, options); return execaSync(file, args, options);
}; }
module.exports.node = (scriptPath, args, options = {}) => { export function execaNode(scriptPath, args, options = {}) {
if (args && !Array.isArray(args) && typeof args === 'object') { if (args && !Array.isArray(args) && typeof args === 'object') {
options = args; options = args;
args = []; args = [];
} }
const stdio = normalizeStdio.node(options); const stdio = normalizeStdioNode(options);
const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect')); const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
const { const {
nodePath = process.execPath, nodePath = process.execPath,
nodeOptions = defaultExecArgv nodeOptions = defaultExecArgv,
} = options; } = options;
return execa( return execa(
@ -254,7 +281,7 @@ module.exports.node = (scriptPath, args, options = {}) => {
[ [
...nodeOptions, ...nodeOptions,
scriptPath, scriptPath,
...(Array.isArray(args) ? args : []) ...(Array.isArray(args) ? args : []),
], ],
{ {
...options, ...options,
@ -262,7 +289,7 @@ module.exports.node = (scriptPath, args, options = {}) => {
stdout: undefined, stdout: undefined,
stderr: undefined, stderr: undefined,
stdio, stdio,
shell: false shell: false,
} },
); );
}; }

70
node_modules/execa/lib/command.js generated vendored
View file

@ -1,4 +1,6 @@
'use strict'; import {Buffer} from 'node:buffer';
import {ChildProcess} from 'node:child_process';
const normalizeArgs = (file, args = []) => { const normalizeArgs = (file, args = []) => {
if (!Array.isArray(args)) { if (!Array.isArray(args)) {
return [file]; return [file];
@ -18,18 +20,14 @@ const escapeArg = arg => {
return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`; return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
}; };
const joinCommand = (file, args) => { export const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
return normalizeArgs(file, args).join(' ');
};
const getEscapedCommand = (file, args) => { export const getEscapedCommand = (file, args) => normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
};
const SPACES_REGEXP = / +/g; const SPACES_REGEXP = / +/g;
// Handle `execa.command()` // Handle `execaCommand()`
const parseCommand = command => { export const parseCommand = command => {
const tokens = []; const tokens = [];
for (const token of command.trim().split(SPACES_REGEXP)) { for (const token of command.trim().split(SPACES_REGEXP)) {
// Allow spaces to be escaped by a backslash if not meant as a delimiter // Allow spaces to be escaped by a backslash if not meant as a delimiter
@ -45,8 +43,54 @@ const parseCommand = command => {
return tokens; return tokens;
}; };
module.exports = { const parseExpression = expression => {
joinCommand, const typeOfExpression = typeof expression;
getEscapedCommand,
parseCommand if (typeOfExpression === 'string') {
return expression;
}
if (typeOfExpression === 'number') {
return String(expression);
}
if (
typeOfExpression === 'object'
&& expression !== null
&& !(expression instanceof ChildProcess)
&& 'stdout' in expression
) {
const typeOfStdout = typeof expression.stdout;
if (typeOfStdout === 'string') {
return expression.stdout;
}
if (Buffer.isBuffer(expression.stdout)) {
return expression.stdout.toString();
}
throw new TypeError(`Unexpected "${typeOfStdout}" stdout in template expression`);
}
throw new TypeError(`Unexpected "${typeOfExpression}" in template expression`);
}; };
const parseTemplate = (template, index, templates, expressions) => {
const templateString = template ?? templates.raw[index];
const templateTokens = templateString.split(SPACES_REGEXP).filter(Boolean);
if (index === expressions.length) {
return templateTokens;
}
const expression = expressions[index];
return Array.isArray(expression)
? [...templateTokens, ...expression.map(expression => parseExpression(expression))]
: [...templateTokens, parseExpression(expression)];
};
export const parseTemplates = (templates, expressions) => templates.flatMap(
(template, index) => parseTemplate(template, index, templates, expressions),
);

9
node_modules/execa/lib/error.js generated vendored
View file

@ -1,5 +1,4 @@
'use strict'; import {signalsByName} from 'human-signals';
const {signalsByName} = require('human-signals');
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
if (timedOut) { if (timedOut) {
@ -25,7 +24,7 @@ const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription
return 'failed'; return 'failed';
}; };
const makeError = ({ export const makeError = ({
stdout, stdout,
stderr, stderr,
all, all,
@ -37,7 +36,7 @@ const makeError = ({
timedOut, timedOut,
isCanceled, isCanceled,
killed, killed,
parsed: {options: {timeout}} parsed: {options: {timeout}},
}) => { }) => {
// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`. // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
// We normalize them to `undefined` // We normalize them to `undefined`
@ -84,5 +83,3 @@ const makeError = ({
return error; return error;
}; };
module.exports = makeError;

33
node_modules/execa/lib/kill.js generated vendored
View file

@ -1,11 +1,10 @@
'use strict'; import os from 'node:os';
const os = require('os'); import onExit from 'signal-exit';
const onExit = require('signal-exit');
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => { export const spawnedKill = (kill, signal = 'SIGTERM', options = {}) => {
const killResult = kill(signal); const killResult = kill(signal);
setKillTimeout(kill, signal, options, killResult); setKillTimeout(kill, signal, options, killResult);
return killResult; return killResult;
@ -30,14 +29,10 @@ const setKillTimeout = (kill, signal, options, killResult) => {
} }
}; };
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => { const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
};
const isSigterm = signal => { const isSigterm = signal => signal === os.constants.signals.SIGTERM
return signal === os.constants.signals.SIGTERM || || (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
(typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
};
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => { const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
if (forceKillAfterTimeout === true) { if (forceKillAfterTimeout === true) {
@ -52,7 +47,7 @@ const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
}; };
// `childProcess.cancel()` // `childProcess.cancel()`
const spawnedCancel = (spawned, context) => { export const spawnedCancel = (spawned, context) => {
const killResult = spawned.kill(); const killResult = spawned.kill();
if (killResult) { if (killResult) {
@ -66,7 +61,7 @@ const timeoutKill = (spawned, signal, reject) => {
}; };
// `timeout` option handling // `timeout` option handling
const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => { export const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
if (timeout === 0 || timeout === undefined) { if (timeout === 0 || timeout === undefined) {
return spawnedPromise; return spawnedPromise;
} }
@ -85,14 +80,14 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise
return Promise.race([timeoutPromise, safeSpawnedPromise]); return Promise.race([timeoutPromise, safeSpawnedPromise]);
}; };
const validateTimeout = ({timeout}) => { export const validateTimeout = ({timeout}) => {
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) { if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`); throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
} }
}; };
// `cleanup` option handling // `cleanup` option handling
const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => { export const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
if (!cleanup || detached) { if (!cleanup || detached) {
return timedPromise; return timedPromise;
} }
@ -105,11 +100,3 @@ const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
removeExitHandler(); removeExitHandler();
}); });
}; };
module.exports = {
spawnedKill,
spawnedCancel,
setupTimeout,
validateTimeout,
setExitHandler
};

42
node_modules/execa/lib/pipe.js generated vendored Normal file
View file

@ -0,0 +1,42 @@
import {createWriteStream} from 'node:fs';
import {ChildProcess} from 'node:child_process';
import {isWritableStream} from 'is-stream';
const isExecaChildProcess = target => target instanceof ChildProcess && typeof target.then === 'function';
const pipeToTarget = (spawned, streamName, target) => {
if (typeof target === 'string') {
spawned[streamName].pipe(createWriteStream(target));
return spawned;
}
if (isWritableStream(target)) {
spawned[streamName].pipe(target);
return spawned;
}
if (!isExecaChildProcess(target)) {
throw new TypeError('The second argument must be a string, a stream or an Execa child process.');
}
if (!isWritableStream(target.stdin)) {
throw new TypeError('The target child process\'s stdin must be available.');
}
spawned[streamName].pipe(target.stdin);
return target;
};
export const addPipeMethods = spawned => {
if (spawned.stdout !== null) {
spawned.pipeStdout = pipeToTarget.bind(undefined, spawned, 'stdout');
}
if (spawned.stderr !== null) {
spawned.pipeStderr = pipeToTarget.bind(undefined, spawned, 'stderr');
}
if (spawned.all !== undefined) {
spawned.pipeAll = pipeToTarget.bind(undefined, spawned, 'all');
}
};

48
node_modules/execa/lib/promise.js generated vendored
View file

@ -1,46 +1,36 @@
'use strict'; // eslint-disable-next-line unicorn/prefer-top-level-await
const nativePromisePrototype = (async () => {})().constructor.prototype; const nativePromisePrototype = (async () => {})().constructor.prototype;
const descriptors = ['then', 'catch', 'finally'].map(property => [ const descriptors = ['then', 'catch', 'finally'].map(property => [
property, property,
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property) Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property),
]); ]);
// The return value is a mixin of `childProcess` and `Promise` // The return value is a mixin of `childProcess` and `Promise`
const mergePromise = (spawned, promise) => { export const mergePromise = (spawned, promise) => {
for (const [property, descriptor] of descriptors) { for (const [property, descriptor] of descriptors) {
// Starting the main `promise` is deferred to avoid consuming streams // Starting the main `promise` is deferred to avoid consuming streams
const value = typeof promise === 'function' ? const value = typeof promise === 'function'
(...args) => Reflect.apply(descriptor.value, promise(), args) : ? (...args) => Reflect.apply(descriptor.value, promise(), args)
descriptor.value.bind(promise); : descriptor.value.bind(promise);
Reflect.defineProperty(spawned, property, {...descriptor, value}); Reflect.defineProperty(spawned, property, {...descriptor, value});
} }
return spawned;
}; };
// Use promises instead of `child_process` events // Use promises instead of `child_process` events
const getSpawnedPromise = spawned => { export const getSpawnedPromise = spawned => new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { spawned.on('exit', (exitCode, signal) => {
spawned.on('exit', (exitCode, signal) => { resolve({exitCode, signal});
resolve({exitCode, signal}); });
});
spawned.on('error', error => { spawned.on('error', error => {
reject(error);
});
if (spawned.stdin) {
spawned.stdin.on('error', error => {
reject(error); reject(error);
}); });
}
if (spawned.stdin) { });
spawned.stdin.on('error', error => {
reject(error);
});
}
});
};
module.exports = {
mergePromise,
getSpawnedPromise
};

7
node_modules/execa/lib/stdio.js generated vendored
View file

@ -1,9 +1,8 @@
'use strict';
const aliases = ['stdin', 'stdout', 'stderr']; const aliases = ['stdin', 'stdout', 'stderr'];
const hasAlias = options => aliases.some(alias => options[alias] !== undefined); const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
const normalizeStdio = options => { export const normalizeStdio = options => {
if (!options) { if (!options) {
return; return;
} }
@ -30,10 +29,8 @@ const normalizeStdio = options => {
return Array.from({length}, (value, index) => stdio[index]); return Array.from({length}, (value, index) => stdio[index]);
}; };
module.exports = normalizeStdio;
// `ipc` is pushed unless it is already present // `ipc` is pushed unless it is already present
module.exports.node = options => { export const normalizeStdioNode = options => {
const stdio = normalizeStdio(options); const stdio = normalizeStdio(options);
if (stdio === 'ipc') { if (stdio === 'ipc') {

76
node_modules/execa/lib/stream.js generated vendored
View file

@ -1,13 +1,48 @@
'use strict'; import {createReadStream, readFileSync} from 'node:fs';
const isStream = require('is-stream'); import {isStream} from 'is-stream';
const getStream = require('get-stream'); import getStream from 'get-stream';
const mergeStream = require('merge-stream'); import mergeStream from 'merge-stream';
// `input` option const validateInputOptions = input => {
const handleInput = (spawned, input) => { if (input !== undefined) {
// Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 throw new TypeError('The `input` and `inputFile` options cannot be both set.');
// @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0 }
if (input === undefined || spawned.stdin === undefined) { };
const getInputSync = ({input, inputFile}) => {
if (typeof inputFile !== 'string') {
return input;
}
validateInputOptions(input);
return readFileSync(inputFile);
};
// `input` and `inputFile` option in sync mode
export const handleInputSync = options => {
const input = getInputSync(options);
if (isStream(input)) {
throw new TypeError('The `input` option cannot be a stream in sync mode');
}
return input;
};
const getInput = ({input, inputFile}) => {
if (typeof inputFile !== 'string') {
return input;
}
validateInputOptions(input);
return createReadStream(inputFile);
};
// `input` and `inputFile` option in async mode
export const handleInput = (spawned, options) => {
const input = getInput(options);
if (input === undefined) {
return; return;
} }
@ -19,7 +54,7 @@ const handleInput = (spawned, input) => {
}; };
// `all` interleaves `stdout` and `stderr` // `all` interleaves `stdout` and `stderr`
const makeAllStream = (spawned, {all}) => { export const makeAllStream = (spawned, {all}) => {
if (!all || (!spawned.stdout && !spawned.stderr)) { if (!all || (!spawned.stdout && !spawned.stderr)) {
return; return;
} }
@ -39,7 +74,8 @@ const makeAllStream = (spawned, {all}) => {
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream // On failure, `result.stdout|stderr|all` should contain the currently buffered stream
const getBufferedData = async (stream, streamPromise) => { const getBufferedData = async (stream, streamPromise) => {
if (!stream) { // When `buffer` is `false`, `streamPromise` is `undefined` and there is no buffered data to retrieve
if (!stream || streamPromise === undefined) {
return; return;
} }
@ -65,7 +101,7 @@ const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
}; };
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all) // Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => { export const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer}); const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer}); const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2}); const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
@ -77,21 +113,7 @@ const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuf
{error, signal: error.signal, timedOut: error.timedOut}, {error, signal: error.signal, timedOut: error.timedOut},
getBufferedData(stdout, stdoutPromise), getBufferedData(stdout, stdoutPromise),
getBufferedData(stderr, stderrPromise), getBufferedData(stderr, stderrPromise),
getBufferedData(all, allPromise) getBufferedData(all, allPromise),
]); ]);
} }
}; };
const validateInputSync = ({input}) => {
if (isStream(input)) {
throw new TypeError('The `input` option cannot be a stream in sync mode');
}
};
module.exports = {
handleInput,
makeAllStream,
getSpawnedResult,
validateInputSync
};

19
node_modules/execa/lib/verbose.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
import {debuglog} from 'node:util';
import process from 'node:process';
export const verboseDefault = debuglog('execa').enabled;
const padField = (field, padding) => String(field).padStart(padding, '0');
const getTimestamp = () => {
const date = new Date();
return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
};
export const logCommand = (escapedCommand, {verbose}) => {
if (!verbose) {
return;
}
process.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`);
};

50
node_modules/execa/package.json generated vendored
View file

@ -1,6 +1,6 @@
{ {
"name": "execa", "name": "execa",
"version": "5.1.1", "version": "7.1.0",
"description": "Process execution for humans", "description": "Process execution for humans",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/execa", "repository": "sindresorhus/execa",
@ -10,11 +10,13 @@
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=10" "node": "^14.18.0 || ^16.14.0 || >=18.0.0"
}, },
"scripts": { "scripts": {
"test": "xo && nyc ava && tsd" "test": "xo && c8 ava && tsd"
}, },
"files": [ "files": [
"index.js", "index.js",
@ -40,27 +42,28 @@
], ],
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"get-stream": "^6.0.0", "get-stream": "^6.0.1",
"human-signals": "^2.1.0", "human-signals": "^4.3.0",
"is-stream": "^2.0.0", "is-stream": "^3.0.0",
"merge-stream": "^2.0.0", "merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1", "npm-run-path": "^5.1.0",
"onetime": "^5.1.2", "onetime": "^6.0.0",
"signal-exit": "^3.0.3", "signal-exit": "^3.0.7",
"strip-final-newline": "^2.0.0" "strip-final-newline": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^14.14.10", "@types/node": "^18.13.0",
"ava": "^2.4.0", "ava": "^5.2.0",
"get-node": "^11.0.1", "c8": "^7.12.0",
"get-node": "^13.5.0",
"is-running": "^2.1.0", "is-running": "^2.1.0",
"nyc": "^15.1.0", "p-event": "^5.0.1",
"p-event": "^4.2.0", "path-key": "^4.0.0",
"tempfile": "^3.0.0", "tempfile": "^4.0.0",
"tsd": "^0.13.1", "tsd": "^0.25.0",
"xo": "^0.35.0" "xo": "^0.53.1"
}, },
"nyc": { "c8": {
"reporter": [ "reporter": [
"text", "text",
"lcov" "lcov"
@ -70,5 +73,14 @@
"**/test.js", "**/test.js",
"**/test/**" "**/test/**"
] ]
},
"ava": {
"workerThreads": false
},
"xo": {
"rules": {
"unicorn/no-empty-file": "off",
"@typescript-eslint/ban-types": "off"
}
} }
} }

441
node_modules/execa/readme.md generated vendored
View file

@ -1,4 +1,7 @@
<img src="media/logo.svg" width="400"> <picture>
<source media="(prefers-color-scheme: dark)" srcset="media/logo_dark.svg">
<img alt="execa logo" src="media/logo.svg" width="400">
</picture>
<br> <br>
[![Coverage Status](https://codecov.io/gh/sindresorhus/execa/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/execa) [![Coverage Status](https://codecov.io/gh/sindresorhus/execa/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/execa)
@ -9,123 +12,173 @@
This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with: This package improves [`child_process`](https://nodejs.org/api/child_process.html) methods with:
- Promise interface. - [Promise interface](#execacommandcommand-options).
- [Scripts interface](#scripts-interface), like `zx`.
- Improved [Windows support](https://github.com/IndigoUnited/node-cross-spawn#why), including [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries.
- Executes [locally installed binaries](#preferlocal) without `npx`.
- [Cleans up](#cleanup) child processes when the parent process ends.
- [Graceful termination](#optionsforcekillaftertimeout).
- Get [interleaved output](#all) from `stdout` and `stderr` similar to what is printed on the terminal.
- [Strips the final newline](#stripfinalnewline) from the output so you don't have to do `stdout.trim()`. - [Strips the final newline](#stripfinalnewline) from the output so you don't have to do `stdout.trim()`.
- Supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) binaries cross-platform. - Convenience methods to pipe processes' [input](#input) and [output](#redirect-output-to-a-file).
- [Improved Windows support.](https://github.com/IndigoUnited/node-cross-spawn#why) - Can specify file and arguments [as a single string](#execacommandcommand-options) without a shell.
- Higher max buffer. 100 MB instead of 200 KB. - [Verbose mode](#verbose-mode) for debugging.
- [Executes locally installed binaries by name.](#preferlocal)
- [Cleans up spawned processes when the parent process dies.](#cleanup)
- [Get interleaved output](#all) from `stdout` and `stderr` similar to what is printed on the terminal. [*(Async only)*](#execasyncfile-arguments-options)
- [Can specify file and arguments as a single string without a shell](#execacommandcommand-options)
- More descriptive errors. - More descriptive errors.
- Higher max buffer: 100 MB instead of 1 MB.
## Install ## Install
``` ```sh
$ npm install execa npm install execa
``` ```
## Usage ## Usage
```js ### Promise interface
const execa = require('execa');
(async () => { ```js
const {stdout} = await execa('echo', ['unicorns']); import {execa} from 'execa';
console.log(stdout);
//=> 'unicorns' const {stdout} = await execa('echo', ['unicorns']);
})(); console.log(stdout);
//=> 'unicorns'
``` ```
### Pipe the child process stdout to the parent ### Scripts interface
For more information about Execa scripts, please see [this page](docs/scripts.md).
#### Basic
```js ```js
const execa = require('execa'); import {$} from 'execa';
execa('echo', ['unicorns']).stdout.pipe(process.stdout); const branch = await $`git branch --show-current`;
await $`dep deploy --branch=${branch}`;
```
#### Multiple arguments
```js
import {$} from 'execa';
const args = ['unicorns', '&', 'rainbows!'];
const {stdout} = await $`echo ${args}`;
console.log(stdout);
//=> 'unicorns & rainbows!'
```
#### With options
```js
import {$} from 'execa';
await $({stdio: 'inherit'})`echo unicorns`;
//=> 'unicorns'
```
#### Shared options
```js
import {$} from 'execa';
const $$ = $({stdio: 'inherit'});
await $$`echo unicorns`;
//=> 'unicorns'
await $$`echo rainbows`;
//=> 'rainbows'
```
#### Verbose mode
```sh
> node file.js
unicorns
rainbows
> NODE_DEBUG=execa node file.js
[16:50:03.305] echo unicorns
unicorns
[16:50:03.308] echo rainbows
rainbows
```
### Input/output
#### Redirect output to a file
```js
import {execa} from 'execa';
// Similar to `echo unicorns > stdout.txt` in Bash
await execa('echo', ['unicorns']).pipeStdout('stdout.txt');
// Similar to `echo unicorns 2> stdout.txt` in Bash
await execa('echo', ['unicorns']).pipeStderr('stderr.txt');
// Similar to `echo unicorns &> stdout.txt` in Bash
await execa('echo', ['unicorns'], {all: true}).pipeAll('all.txt');
```
#### Redirect input from a file
```js
import {execa} from 'execa';
// Similar to `cat < stdin.txt` in Bash
const {stdout} = await execa('cat', {inputFile: 'stdin.txt'});
console.log(stdout);
//=> 'unicorns'
```
#### Save and pipe output from a child process
```js
import {execa} from 'execa';
const {stdout} = await execa('echo', ['unicorns']).pipeStdout(process.stdout);
// Prints `unicorns`
console.log(stdout);
// Also returns 'unicorns'
```
#### Pipe multiple processes
```js
import {execa} from 'execa';
// Similar to `echo unicorns | cat` in Bash
const {stdout} = await execa('echo', ['unicorns']).pipeStdout(execa('cat'));
console.log(stdout);
//=> 'unicorns'
``` ```
### Handling Errors ### Handling Errors
```js ```js
const execa = require('execa'); import {execa} from 'execa';
(async () => { // Catching an error
// Catching an error
try {
await execa('unknown', ['command']);
} catch (error) {
console.log(error);
/*
{
message: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
errno: -2,
code: 'ENOENT',
syscall: 'spawn unknown',
path: 'unknown',
spawnargs: ['command'],
originalMessage: 'spawn unknown ENOENT',
shortMessage: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
command: 'unknown command',
escapedCommand: 'unknown command',
stdout: '',
stderr: '',
all: '',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
*/
}
})();
```
### Cancelling a spawned process
```js
const execa = require('execa');
(async () => {
const subprocess = execa('node');
setTimeout(() => {
subprocess.cancel();
}, 1000);
try {
await subprocess;
} catch (error) {
console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
}
})()
```
### Catching an error with the sync method
```js
try { try {
execa.sync('unknown', ['command']); await execa('unknown', ['command']);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
/* /*
{ {
message: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT', message: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
errno: -2, errno: -2,
code: 'ENOENT', code: 'ENOENT',
syscall: 'spawnSync unknown', syscall: 'spawn unknown',
path: 'unknown', path: 'unknown',
spawnargs: ['command'], spawnargs: ['command'],
originalMessage: 'spawnSync unknown ENOENT', originalMessage: 'spawn unknown ENOENT',
shortMessage: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT', shortMessage: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',
command: 'unknown command', command: 'unknown command',
escapedCommand: 'unknown command', escapedCommand: 'unknown command',
stdout: '', stdout: '',
stderr: '', stderr: '',
all: '',
failed: true, failed: true,
timedOut: false, timedOut: false,
isCanceled: false, isCanceled: false,
@ -135,7 +188,7 @@ try {
} }
``` ```
### Kill a process ### Graceful termination
Using SIGTERM, and after 2 seconds, kill it with SIGKILL. Using SIGTERM, and after 2 seconds, kill it with SIGKILL.
@ -151,17 +204,84 @@ setTimeout(() => {
## API ## API
### execa(file, arguments, options?) ### Methods
Execute a file. Think of this as a mix of [`child_process.execFile()`](https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback) and [`child_process.spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). #### execa(file, arguments?, options?)
No escaping/quoting is needed. Executes a command using `file ...arguments`. `arguments` are specified as an array of strings. Returns a [`childProcess`](#childprocess).
Unless the [`shell`](#shell) option is used, no shell interpreter (Bash, `cmd.exe`, etc.) is used, so shell features such as variables substitution (`echo $PATH`) are not allowed. Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.
Returns a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) which: This is the preferred method when executing single commands.
- is also a `Promise` resolving or rejecting with a [`childProcessResult`](#childProcessResult).
- exposes the following additional methods and properties. #### execaNode(scriptPath, arguments?, options?)
Executes a Node.js file using `node scriptPath ...arguments`. `arguments` are specified as an array of strings. Returns a [`childProcess`](#childprocess).
Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.
This is the preferred method when executing Node.js files.
Like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options):
- the current Node version and options are used. This can be overridden using the [`nodePath`](#nodepath-for-node-only) and [`nodeOptions`](#nodeoptions-for-node-only) options.
- the [`shell`](#shell) option cannot be used
- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio)
#### $\`command\`
Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).
Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.
This is the preferred method when executing multiple commands in a script file.
The `command` string can inject any `${value}` with the following types: string, number, [`childProcess`](#childprocess) or an array of those types. For example: `` $`echo one ${'two'} ${3} ${['four', 'five']}` ``. For `${childProcess}`, the process's `stdout` is used.
For more information, please see [this section](#scripts-interface) and [this page](docs/scripts.md).
#### $(options)
Returns a new instance of [`$`](#command) but with different default `options`. Consecutive calls are merged to previous ones.
This can be used to either:
- Set options for a specific command: `` $(options)`command` ``
- Share options for multiple commands: `` const $$ = $(options); $$`command`; $$`otherCommand`; ``
#### execaCommand(command, options?)
Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).
Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.
This is the preferred method when executing a user-supplied `command` string, such as in a REPL.
### execaSync(file, arguments?, options?)
Same as [`execa()`](#execacommandcommand-options) but synchronous.
Returns or throws a [`childProcessResult`](#childProcessResult).
### $.sync\`command\`
Same as [$\`command\`](#command) but synchronous.
Returns or throws a [`childProcessResult`](#childProcessResult).
### execaCommandSync(command, options?)
Same as [`execaCommand()`](#execacommand-command-options) but synchronous.
Returns or throws a [`childProcessResult`](#childProcessResult).
### Shell syntax
For all the [methods above](#methods), no shell interpreter (Bash, cmd.exe, etc.) is used unless the [`shell` option](#shell) is set. This means shell-specific characters and expressions (`$variable`, `&&`, `||`, `;`, `|`, etc.) have no special meaning and do not need to be escaped.
### childProcess
The return value of all [asynchronous methods](#methods) is both:
- a `Promise` resolving or rejecting with a [`childProcessResult`](#childProcessResult).
- a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following additional methods and properties.
#### kill(signal?, options?) #### kill(signal?, options?)
@ -176,10 +296,6 @@ Milliseconds to wait for the child process to terminate before sending `SIGKILL`
Can be disabled with `false`. Can be disabled with `false`.
#### cancel()
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`.
#### all #### all
Type: `ReadableStream | undefined` Type: `ReadableStream | undefined`
@ -190,34 +306,28 @@ This is `undefined` if either:
- the [`all` option](#all-2) is `false` (the default value) - the [`all` option](#all-2) is `false` (the default value)
- both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio) - both [`stdout`](#stdout-1) and [`stderr`](#stderr-1) options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
### execa.sync(file, arguments?, options?) #### pipeStdout(target)
Execute a file synchronously. [Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process's `stdout` to `target`, which can be:
- Another [`execa()` return value](#pipe-multiple-processes)
- A [writable stream](#save-and-pipe-output-from-a-child-process)
- A [file path string](#redirect-output-to-a-file)
Returns or throws a [`childProcessResult`](#childProcessResult). If the `target` is another [`execa()` return value](#execacommandcommand-options), it is returned. Otherwise, the original `execa()` return value is returned. This allows chaining `pipeStdout()` then `await`ing the [final result](#childprocessresult).
### execa.command(command, options?) The [`stdout` option](#stdout-1) must be kept as `pipe`, its default value.
Same as [`execa()`](#execafile-arguments-options) except both file and arguments are specified in a single `command` string. For example, `execa('echo', ['unicorns'])` is the same as `execa.command('echo unicorns')`. #### pipeStderr(target)
If the file or an argument contains spaces, they must be escaped with backslashes. This matters especially if `command` is not a constant but a variable, for example with `__dirname` or `process.cwd()`. Except for spaces, no escaping/quoting is needed. Like [`pipeStdout()`](#pipestdouttarget) but piping the child process's `stderr` instead.
The [`shell` option](#shell) must be used if the `command` uses shell-specific features (for example, `&&` or `||`), as opposed to being a simple `file` followed by its `arguments`. The [`stderr` option](#stderr-1) must be kept as `pipe`, its default value.
### execa.commandSync(command, options?) #### pipeAll(target)
Same as [`execa.command()`](#execacommand-command-options) but synchronous. Combines both [`pipeStdout()`](#pipestdouttarget) and [`pipeStderr()`](#pipestderrtarget).
Returns or throws a [`childProcessResult`](#childProcessResult). Either the [`stdout` option](#stdout-1) or the [`stderr` option](#stderr-1) must be kept as `pipe`, their default value. Also, the [`all` option](#all-2) must be set to `true`.
### execa.node(scriptPath, arguments?, options?)
Execute a Node.js script as a child process.
Same as `execa('node', [scriptPath, ...arguments], options)` except (like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)):
- the current Node version and options are used. This can be overridden using the [`nodePath`](#nodepath-for-node-only) and [`nodeOptions`](#nodeoptions-for-node-only) options.
- the [`shell`](#shell) option cannot be used
- an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to [`stdio`](#stdio)
### childProcessResult ### childProcessResult
@ -238,16 +348,16 @@ Type: `string`
The file and arguments that were run, for logging purposes. The file and arguments that were run, for logging purposes.
This is not escaped and should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execa.command()`](#execacommandcommand-options). This is not escaped and should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).
#### escapedCommand #### escapedCommand
Type: `string` Type: `string`
Same as [`command`](#command) but escaped. Same as [`command`](#command-1) but escaped.
This is meant to be copy and pasted into a shell, for debugging purposes. This is meant to be copy and pasted into a shell, for debugging purposes.
Since the escaping is fairly basic, this should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execa.command()`](#execacommandcommand-options). Since the escaping is fairly basic, this should not be executed directly as a process, including using [`execa()`](#execafile-arguments-options) or [`execaCommand()`](#execacommandcommand-options).
#### exitCode #### exitCode
@ -275,7 +385,7 @@ The output of the process with `stdout` and `stderr` interleaved.
This is `undefined` if either: This is `undefined` if either:
- the [`all` option](#all-2) is `false` (the default value) - the [`all` option](#all-2) is `false` (the default value)
- `execa.sync()` was used - `execaSync()` was used
#### failed #### failed
@ -295,6 +405,8 @@ Type: `boolean`
Whether the process was canceled. Whether the process was canceled.
You can cancel the spawned process using the [`signal`](#signal-1) option.
#### killed #### killed
Type: `boolean` Type: `boolean`
@ -355,14 +467,14 @@ Kill the spawned process when the parent process exits unless either:
#### preferLocal #### preferLocal
Type: `boolean`\ Type: `boolean`\
Default: `false` Default: `true` with [`$`](#command)/[`$.sync`](#synccommand), `false` otherwise
Prefer locally installed binaries when looking for a binary to execute.\ Prefer locally installed binaries when looking for a binary to execute.\
If you `$ npm install foo`, you can then `execa('foo')`. If you `$ npm install foo`, you can then `execa('foo')`.
#### localDir #### localDir
Type: `string`\ Type: `string | URL`\
Default: `process.cwd()` Default: `process.cwd()`
Preferred path to find locally installed binaries in (use with `preferLocal`). Preferred path to find locally installed binaries in (use with `preferLocal`).
@ -396,6 +508,16 @@ Type: `string | Buffer | stream.Readable`
Write some input to the `stdin` of your binary.\ Write some input to the `stdin` of your binary.\
Streams are not allowed when using the synchronous methods. Streams are not allowed when using the synchronous methods.
If the input is a file, use the [`inputFile` option](#inputfile) instead.
#### inputFile
Type: `string`
Use a file as input to the the `stdin` of your binary.
If the input is not a file, use the [`input` option](#input) instead.
#### stdin #### stdin
Type: `string | number | Stream | undefined`\ Type: `string | number | Stream | undefined`\
@ -451,7 +573,7 @@ Execa also accepts the below options which are the same as the options for [`chi
#### cwd #### cwd
Type: `string`\ Type: `string | URL`\
Default: `process.cwd()` Default: `process.cwd()`
Current working directory of the child process. Current working directory of the child process.
@ -481,12 +603,10 @@ Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_
Type: `string`\ Type: `string`\
Default: `'json'` Default: `'json'`
Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execa.node()`](#execanodescriptpath-arguments-options): Specify the kind of serialization used for sending messages between processes when using the [`stdio: 'ipc'`](#stdio) option or [`execaNode()`](#execanodescriptpath-arguments-options):
- `json`: Uses `JSON.stringify()` and `JSON.parse()`. - `json`: Uses `JSON.stringify()` and `JSON.parse()`.
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value) - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
Requires Node.js `13.2.0` or later.
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization) [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
#### detached #### detached
@ -547,6 +667,16 @@ Default: `SIGTERM`
Signal value to be used when the spawned process will be killed. Signal value to be used when the spawned process will be killed.
#### signal
Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `false`.
*Requires Node.js 16 or later.*
#### windowsVerbatimArguments #### windowsVerbatimArguments
Type: `boolean`\ Type: `boolean`\
@ -561,6 +691,15 @@ Default: `true`
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows. On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
#### verbose
Type: `boolean`\
Default: `false`
[Print each command](#verbose-mode) on `stderr` before executing it.
This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.
#### nodePath *(For `.node()` only)* #### nodePath *(For `.node()` only)*
Type: `string`\ Type: `string`\
@ -582,59 +721,43 @@ List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the
Gracefully handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package: Gracefully handle failures by using automatic retries and exponential backoff with the [`p-retry`](https://github.com/sindresorhus/p-retry) package:
```js ```js
const pRetry = require('p-retry'); import pRetry from 'p-retry';
const run = async () => { const run = async () => {
const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']); const results = await execa('curl', ['-sSL', 'https://sindresorhus.com/unicorn']);
return results; return results;
}; };
(async () => { console.log(await pRetry(run, {retries: 5}));
console.log(await pRetry(run, {retries: 5}));
})();
``` ```
### Save and pipe output from a child process ### Cancelling a spawned process
Let's say you want to show the output of a child process in real-time while also saving it to a variable.
```js ```js
const execa = require('execa'); import {execa} from 'execa';
const subprocess = execa('echo', ['foo']); const abortController = new AbortController();
subprocess.stdout.pipe(process.stdout); const subprocess = execa('node', [], {signal: abortController.signal});
(async () => { setTimeout(() => {
const {stdout} = await subprocess; abortController.abort();
console.log('child output:', stdout); }, 1000);
})();
```
### Redirect output to a file try {
await subprocess;
```js } catch (error) {
const execa = require('execa'); console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
const subprocess = execa('echo', ['foo']) }
subprocess.stdout.pipe(fs.createWriteStream('stdout.txt'))
```
### Redirect input from a file
```js
const execa = require('execa');
const subprocess = execa('cat')
fs.createReadStream('stdin.txt').pipe(subprocess.stdin)
``` ```
### Execute the current package's binary ### Execute the current package's binary
```js ```js
const {getBinPathSync} = require('get-bin-path'); import {getBinPath} from 'get-bin-path';
const binPath = getBinPathSync(); const binPath = await getBinPath();
const subprocess = execa(binPath); await execa(binPath);
``` ```
`execa` can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up. `execa` can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up.

View file

@ -1,11 +0,0 @@
# 2.1.0
## TypeScript types
- Add [TypeScript definitions](src/main.d.ts)
# 2.0.0
## Breaking changes
- Minimal supported Node.js version is now `10.17.0`

2
node_modules/human-signals/LICENSE generated vendored
View file

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2019 ehmicky <ehmicky@gmail.com> Copyright 2022 ehmicky <ehmicky@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

26
node_modules/human-signals/README.md generated vendored
View file

@ -1,9 +1,8 @@
[![Codecov](https://img.shields.io/codecov/c/github/ehmicky/human-signals.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/human-signals) [![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js&colorA=404040&logoColor=66cc33)](https://www.npmjs.com/package/human-signals)
[![Travis](https://img.shields.io/badge/cross-platform-4cc61e.svg?logo=travis)](https://travis-ci.org/ehmicky/human-signals) [![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript&colorA=404040&logoColor=0096ff)](/types/main.d.ts)
[![Node](https://img.shields.io/node/v/human-signals.svg?logo=node.js)](https://www.npmjs.com/package/human-signals) [![Codecov](https://img.shields.io/badge/-Tested%20100%25-808080?logo=codecov&colorA=404040)](https://codecov.io/gh/ehmicky/human-signals)
[![Gitter](https://img.shields.io/gitter/room/ehmicky/human-signals.svg?logo=gitter)](https://gitter.im/ehmicky/human-signals) [![Twitter](https://img.shields.io/badge/-Twitter-808080.svg?logo=twitter&colorA=404040)](https://twitter.com/intent/follow?screen_name=ehmicky)
[![Twitter](https://img.shields.io/badge/%E2%80%8B-twitter-4cc61e.svg?logo=twitter)](https://twitter.com/intent/follow?screen_name=ehmicky) [![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium&colorA=404040)](https://medium.com/@ehmicky)
[![Medium](https://img.shields.io/badge/%E2%80%8B-medium-4cc61e.svg?logo=medium)](https://medium.com/@ehmicky)
Human-friendly process signals. Human-friendly process signals.
@ -20,7 +19,7 @@ this includes:
# Example # Example
```js ```js
const { signalsByName, signalsByNumber } = require('human-signals') import { signalsByName, signalsByNumber } from 'human-signals'
console.log(signalsByName.SIGINT) console.log(signalsByName.SIGINT)
// { // {
@ -51,6 +50,11 @@ console.log(signalsByNumber[8])
npm install human-signals npm install human-signals
``` ```
This package works in Node.js >=14.18.0. It is an ES module and must be loaded
using
[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),
not `require()`.
# Usage # Usage
## signalsByName ## signalsByName
@ -101,7 +105,7 @@ Whether the current OS can handle this signal in Node.js using
[`process.on(name, handler)`](https://nodejs.org/api/process.html#process_signal_events). [`process.on(name, handler)`](https://nodejs.org/api/process.html#process_signal_events).
The list of supported signals The list of supported signals
[is OS-specific](https://github.com/ehmicky/cross-platform-node-guide/blob/master/docs/6_networking_ipc/signals.md#cross-platform-signals). [is OS-specific](https://github.com/ehmicky/cross-platform-node-guide/blob/main/docs/6_networking_ipc/signals.md#cross-platform-signals).
### action ### action
@ -126,11 +130,7 @@ Which standard defined that signal.
# Support # Support
If you found a bug or would like a new feature, _don't hesitate_ to For any question, _don't hesitate_ to [submit an issue on GitHub](../../issues).
[submit an issue on GitHub](../../issues).
For other questions, feel free to
[chat with us on Gitter](https://gitter.im/ehmicky/human-signals).
Everyone is welcome regardless of personal background. We enforce a Everyone is welcome regardless of personal background. We enforce a
[Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and [Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and

View file

@ -1,6 +1,6 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SIGNALS=void 0;
const SIGNALS=[
export const SIGNALS=[
{ {
name:"SIGHUP", name:"SIGHUP",
number:1, number:1,
@ -269,5 +269,5 @@ name:"SIGUNUSED",
number:31, number:31,
action:"terminate", action:"terminate",
description:"Invalid system call", description:"Invalid system call",
standard:"other"}];exports.SIGNALS=SIGNALS; standard:"other"}];
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,52 +0,0 @@
/**
* Object whose keys are signal names and values are signal objects.
*/
export declare const signalsByName: { [signalName: string]: Signal }
/**
* Object whose keys are signal numbers and values are signal objects.
*/
export declare const signalsByNumber: { [signalNumber: string]: Signal }
export declare type SignalAction =
| 'terminate'
| 'core'
| 'ignore'
| 'pause'
| 'unpause'
export declare type SignalStandard =
| 'ansi'
| 'posix'
| 'bsd'
| 'systemv'
| 'other'
export declare type Signal = {
/**
* Standard name of the signal, for example 'SIGINT'.
*/
name: string
/**
* Code number of the signal, for example 2. While most number are cross-platform, some are different between different OS.
*/
number: number
/**
* Human-friendly description for the signal, for example 'User interruption with CTRL-C'.
*/
description: string
/**
* Whether the current OS can handle this signal in Node.js using process.on(name, handler). The list of supported signals is OS-specific.
*/
supported: boolean
/**
* What is the default action for this signal when it is not handled.
*/
action: SignalAction
/**
* Whether the signal's default action cannot be prevented. This is true for SIGTERM, SIGKILL and SIGSTOP.
*/
forced: boolean
/**
* Which standard defined that signal.
*/
standard: SignalStandard
}

View file

@ -1,33 +1,38 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.signalsByNumber=exports.signalsByName=void 0;var _os=require("os"); import{constants}from"node:os";
var _signals=require("./signals.js"); import{SIGRTMAX}from"./realtime.js";
var _realtime=require("./realtime.js"); import{getSignals}from"./signals.js";
const getSignalsByName=function(){ const getSignalsByName=function(){
const signals=(0,_signals.getSignals)(); const signals=getSignals();
return signals.reduce(getSignalByName,{}); return Object.fromEntries(signals.map(getSignalByName));
}; };
const getSignalByName=function( const getSignalByName=function({
signalByNameMemo, name,
{name,number,description,supported,action,forced,standard}) number,
description,
supported,
action,
forced,
standard})
{ {
return{ return[
...signalByNameMemo, name,
[name]:{name,number,description,supported,action,forced,standard}}; {name,number,description,supported,action,forced,standard}];
}; };
const signalsByName=getSignalsByName();exports.signalsByName=signalsByName; export const signalsByName=getSignalsByName();
const getSignalsByNumber=function(){ const getSignalsByNumber=function(){
const signals=(0,_signals.getSignals)(); const signals=getSignals();
const length=_realtime.SIGRTMAX+1; const length=SIGRTMAX+1;
const signalsA=Array.from({length},(value,number)=> const signalsA=Array.from({length},(value,number)=>
getSignalByNumber(number,signals)); getSignalByNumber(number,signals));
@ -58,14 +63,14 @@ standard}};
const findSignalByNumber=function(number,signals){ const findSignalByNumber=function(number,signals){
const signal=signals.find(({name})=>_os.constants.signals[name]===number); const signal=signals.find(({name})=>constants.signals[name]===number);
if(signal!==undefined){ if(signal!==undefined){
return signal; return signal;
} }
return signals.find(signalA=>signalA.number===number); return signals.find((signalA)=>signalA.number===number);
}; };
const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber; export const signalsByNumber=getSignalsByNumber();
//# sourceMappingURL=main.js.map //# sourceMappingURL=main.js.map

View file

@ -1 +0,0 @@
{"version":3,"sources":["../../src/main.js"],"names":["getSignalsByName","signals","reduce","getSignalByName","signalByNameMemo","name","number","description","supported","action","forced","standard","signalsByName","getSignalsByNumber","length","SIGRTMAX","signalsA","Array","from","value","getSignalByNumber","Object","assign","signal","findSignalByNumber","undefined","find","constants","signalA","signalsByNumber"],"mappings":"2HAAA;;AAEA;AACA;;;;AAIA,KAAMA,CAAAA,gBAAgB,CAAG,UAAW;AAClC,KAAMC,CAAAA,OAAO,CAAG,yBAAhB;AACA,MAAOA,CAAAA,OAAO,CAACC,MAAR,CAAeC,eAAf,CAAgC,EAAhC,CAAP;AACD,CAHD;;AAKA,KAAMA,CAAAA,eAAe,CAAG;AACtBC,gBADsB;AAEtB,CAAEC,IAAF,CAAQC,MAAR,CAAgBC,WAAhB,CAA6BC,SAA7B,CAAwCC,MAAxC,CAAgDC,MAAhD,CAAwDC,QAAxD,CAFsB;AAGtB;AACA,MAAO;AACL,GAAGP,gBADE;AAEL,CAACC,IAAD,EAAQ,CAAEA,IAAF,CAAQC,MAAR,CAAgBC,WAAhB,CAA6BC,SAA7B,CAAwCC,MAAxC,CAAgDC,MAAhD,CAAwDC,QAAxD,CAFH,CAAP;;AAID,CARD;;AAUO,KAAMC,CAAAA,aAAa,CAAGZ,gBAAgB,EAAtC,C;;;;;AAKP,KAAMa,CAAAA,kBAAkB,CAAG,UAAW;AACpC,KAAMZ,CAAAA,OAAO,CAAG,yBAAhB;AACA,KAAMa,CAAAA,MAAM,CAAGC,mBAAW,CAA1B;AACA,KAAMC,CAAAA,QAAQ,CAAGC,KAAK,CAACC,IAAN,CAAW,CAAEJ,MAAF,CAAX,CAAuB,CAACK,KAAD,CAAQb,MAAR;AACtCc,iBAAiB,CAACd,MAAD,CAASL,OAAT,CADF,CAAjB;;AAGA,MAAOoB,CAAAA,MAAM,CAACC,MAAP,CAAc,EAAd,CAAkB,GAAGN,QAArB,CAAP;AACD,CAPD;;AASA,KAAMI,CAAAA,iBAAiB,CAAG,SAASd,MAAT,CAAiBL,OAAjB,CAA0B;AAClD,KAAMsB,CAAAA,MAAM,CAAGC,kBAAkB,CAAClB,MAAD,CAASL,OAAT,CAAjC;;AAEA,GAAIsB,MAAM,GAAKE,SAAf,CAA0B;AACxB,MAAO,EAAP;AACD;;AAED,KAAM,CAAEpB,IAAF,CAAQE,WAAR,CAAqBC,SAArB,CAAgCC,MAAhC,CAAwCC,MAAxC,CAAgDC,QAAhD,EAA6DY,MAAnE;AACA,MAAO;AACL,CAACjB,MAAD,EAAU;AACRD,IADQ;AAERC,MAFQ;AAGRC,WAHQ;AAIRC,SAJQ;AAKRC,MALQ;AAMRC,MANQ;AAORC,QAPQ,CADL,CAAP;;;AAWD,CAnBD;;;;AAuBA,KAAMa,CAAAA,kBAAkB,CAAG,SAASlB,MAAT,CAAiBL,OAAjB,CAA0B;AACnD,KAAMsB,CAAAA,MAAM,CAAGtB,OAAO,CAACyB,IAAR,CAAa,CAAC,CAAErB,IAAF,CAAD,GAAcsB,cAAU1B,OAAV,CAAkBI,IAAlB,IAA4BC,MAAvD,CAAf;;AAEA,GAAIiB,MAAM,GAAKE,SAAf,CAA0B;AACxB,MAAOF,CAAAA,MAAP;AACD;;AAED,MAAOtB,CAAAA,OAAO,CAACyB,IAAR,CAAaE,OAAO,EAAIA,OAAO,CAACtB,MAAR,GAAmBA,MAA3C,CAAP;AACD,CARD;;AAUO,KAAMuB,CAAAA,eAAe,CAAGhB,kBAAkB,EAA1C,C","sourcesContent":["import { constants } from 'os'\n\nimport { getSignals } from './signals.js'\nimport { SIGRTMAX } from './realtime.js'\n\n// Retrieve `signalsByName`, an object mapping signal name to signal properties.\n// We make sure the object is sorted by `number`.\nconst getSignalsByName = function() {\n const signals = getSignals()\n return signals.reduce(getSignalByName, {})\n}\n\nconst getSignalByName = function(\n signalByNameMemo,\n { name, number, description, supported, action, forced, standard },\n) {\n return {\n ...signalByNameMemo,\n [name]: { name, number, description, supported, action, forced, standard },\n }\n}\n\nexport const signalsByName = getSignalsByName()\n\n// Retrieve `signalsByNumber`, an object mapping signal number to signal\n// properties.\n// We make sure the object is sorted by `number`.\nconst getSignalsByNumber = function() {\n const signals = getSignals()\n const length = SIGRTMAX + 1\n const signalsA = Array.from({ length }, (value, number) =>\n getSignalByNumber(number, signals),\n )\n return Object.assign({}, ...signalsA)\n}\n\nconst getSignalByNumber = function(number, signals) {\n const signal = findSignalByNumber(number, signals)\n\n if (signal === undefined) {\n return {}\n }\n\n const { name, description, supported, action, forced, standard } = signal\n return {\n [number]: {\n name,\n number,\n description,\n supported,\n action,\n forced,\n standard,\n },\n }\n}\n\n// Several signals might end up sharing the same number because of OS-specific\n// numbers, in which case those prevail.\nconst findSignalByNumber = function(number, signals) {\n const signal = signals.find(({ name }) => constants.signals[name] === number)\n\n if (signal !== undefined) {\n return signal\n }\n\n return signals.find(signalA => signalA.number === number)\n}\n\nexport const signalsByNumber = getSignalsByNumber()\n"],"file":"src/main.js"}

View file

@ -1,8 +1,8 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SIGRTMAX=exports.getRealtimeSignals=void 0;
const getRealtimeSignals=function(){ export const getRealtimeSignals=function(){
const length=SIGRTMAX-SIGRTMIN+1; const length=SIGRTMAX-SIGRTMIN+1;
return Array.from({length},getRealtimeSignal); return Array.from({length},getRealtimeSignal);
};exports.getRealtimeSignals=getRealtimeSignals; };
const getRealtimeSignal=function(value,index){ const getRealtimeSignal=function(value,index){
return{ return{
@ -15,5 +15,5 @@ standard:"posix"};
}; };
const SIGRTMIN=34; const SIGRTMIN=34;
const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; export const SIGRTMAX=64;
//# sourceMappingURL=realtime.js.map //# sourceMappingURL=realtime.js.map

View file

@ -1 +0,0 @@
{"version":3,"sources":["../../src/realtime.js"],"names":["getRealtimeSignals","length","SIGRTMAX","SIGRTMIN","Array","from","getRealtimeSignal","value","index","name","number","action","description","standard"],"mappings":";AACO,KAAMA,CAAAA,kBAAkB,CAAG,UAAW;AAC3C,KAAMC,CAAAA,MAAM,CAAGC,QAAQ,CAAGC,QAAX,CAAsB,CAArC;AACA,MAAOC,CAAAA,KAAK,CAACC,IAAN,CAAW,CAAEJ,MAAF,CAAX,CAAuBK,iBAAvB,CAAP;AACD,CAHM,C;;AAKP,KAAMA,CAAAA,iBAAiB,CAAG,SAASC,KAAT,CAAgBC,KAAhB,CAAuB;AAC/C,MAAO;AACLC,IAAI,CAAG,QAAOD,KAAK,CAAG,CAAE,EADnB;AAELE,MAAM,CAAEP,QAAQ,CAAGK,KAFd;AAGLG,MAAM,CAAE,WAHH;AAILC,WAAW,CAAE,wCAJR;AAKLC,QAAQ,CAAE,OALL,CAAP;;AAOD,CARD;;AAUA,KAAMV,CAAAA,QAAQ,CAAG,EAAjB;AACO,KAAMD,CAAAA,QAAQ,CAAG,EAAjB,C","sourcesContent":["// List of realtime signals with information about them\nexport const getRealtimeSignals = function() {\n const length = SIGRTMAX - SIGRTMIN + 1\n return Array.from({ length }, getRealtimeSignal)\n}\n\nconst getRealtimeSignal = function(value, index) {\n return {\n name: `SIGRT${index + 1}`,\n number: SIGRTMIN + index,\n action: 'terminate',\n description: 'Application-specific signal (realtime)',\n standard: 'posix',\n }\n}\n\nconst SIGRTMIN = 34\nexport const SIGRTMAX = 64\n"],"file":"src/realtime.js"}

View file

@ -1,15 +1,15 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getSignals=void 0;var _os=require("os"); import{constants}from"node:os";
var _core=require("./core.js"); import{SIGNALS}from"./core.js";
var _realtime=require("./realtime.js"); import{getRealtimeSignals}from"./realtime.js";
const getSignals=function(){ export const getSignals=function(){
const realtimeSignals=(0,_realtime.getRealtimeSignals)(); const realtimeSignals=getRealtimeSignals();
const signals=[..._core.SIGNALS,...realtimeSignals].map(normalizeSignal); const signals=[...SIGNALS,...realtimeSignals].map(normalizeSignal);
return signals; return signals;
};exports.getSignals=getSignals; };
@ -27,7 +27,7 @@ standard})
{ {
const{ const{
signals:{[name]:constantSignal}}= signals:{[name]:constantSignal}}=
_os.constants; constants;
const supported=constantSignal!==undefined; const supported=constantSignal!==undefined;
const number=supported?constantSignal:defaultNumber; const number=supported?constantSignal:defaultNumber;
return{name,number,description,supported,action,forced,standard}; return{name,number,description,supported,action,forced,standard};

View file

@ -1 +0,0 @@
{"version":3,"sources":["../../src/signals.js"],"names":["getSignals","realtimeSignals","signals","SIGNALS","map","normalizeSignal","name","number","defaultNumber","description","action","forced","standard","constantSignal","constants","supported","undefined"],"mappings":"gGAAA;;AAEA;AACA;;;;AAIO,KAAMA,CAAAA,UAAU,CAAG,UAAW;AACnC,KAAMC,CAAAA,eAAe,CAAG,kCAAxB;AACA,KAAMC,CAAAA,OAAO,CAAG,CAAC,GAAGC,aAAJ,CAAa,GAAGF,eAAhB,EAAiCG,GAAjC,CAAqCC,eAArC,CAAhB;AACA,MAAOH,CAAAA,OAAP;AACD,CAJM,C;;;;;;;;AAYP,KAAMG,CAAAA,eAAe,CAAG,SAAS;AAC/BC,IAD+B;AAE/BC,MAAM,CAAEC,aAFuB;AAG/BC,WAH+B;AAI/BC,MAJ+B;AAK/BC,MAAM,CAAG,KALsB;AAM/BC,QAN+B,CAAT;AAOrB;AACD,KAAM;AACJV,OAAO,CAAE,CAAE,CAACI,IAAD,EAAQO,cAAV,CADL;AAEFC,aAFJ;AAGA,KAAMC,CAAAA,SAAS,CAAGF,cAAc,GAAKG,SAArC;AACA,KAAMT,CAAAA,MAAM,CAAGQ,SAAS,CAAGF,cAAH,CAAoBL,aAA5C;AACA,MAAO,CAAEF,IAAF,CAAQC,MAAR,CAAgBE,WAAhB,CAA6BM,SAA7B,CAAwCL,MAAxC,CAAgDC,MAAhD,CAAwDC,QAAxD,CAAP;AACD,CAdD","sourcesContent":["import { constants } from 'os'\n\nimport { SIGNALS } from './core.js'\nimport { getRealtimeSignals } from './realtime.js'\n\n// Retrieve list of know signals (including realtime) with information about\n// them\nexport const getSignals = function() {\n const realtimeSignals = getRealtimeSignals()\n const signals = [...SIGNALS, ...realtimeSignals].map(normalizeSignal)\n return signals\n}\n\n// Normalize signal:\n// - `number`: signal numbers are OS-specific. This is taken into account by\n// `os.constants.signals`. However we provide a default `number` since some\n// signals are not defined for some OS.\n// - `forced`: set default to `false`\n// - `supported`: set value\nconst normalizeSignal = function({\n name,\n number: defaultNumber,\n description,\n action,\n forced = false,\n standard,\n}) {\n const {\n signals: { [name]: constantSignal },\n } = constants\n const supported = constantSignal !== undefined\n const number = supported ? constantSignal : defaultNumber\n return { name, number, description, supported, action, forced, standard }\n}\n"],"file":"src/signals.js"}

73
node_modules/human-signals/build/types/main.d.ts generated vendored Normal file
View file

@ -0,0 +1,73 @@
/**
* What is the default action for this signal when it is not handled.
*/
export type SignalAction = 'terminate' | 'core' | 'ignore' | 'pause' | 'unpause'
/**
* Which standard defined that signal.
*/
export type SignalStandard = 'ansi' | 'posix' | 'bsd' | 'systemv' | 'other'
/**
* Standard name of the signal, for example 'SIGINT'.
*/
export type SignalName = `SIG${string}`
/**
* Code number of the signal, for example 2.
* While most number are cross-platform, some are different between different
* OS.
*/
export type SignalNumber = number
export type Signal = {
/**
* Standard name of the signal, for example 'SIGINT'.
*/
name: SignalName
/**
* Code number of the signal, for example 2.
* While most number are cross-platform, some are different between different
* OS.
*/
number: SignalNumber
/**
* Human-friendly description for the signal, for example
* 'User interruption with CTRL-C'.
*/
description: string
/**
* Whether the current OS can handle this signal in Node.js using
* `process.on(name, handler)`. The list of supported signals is OS-specific.
*/
supported: boolean
/**
* What is the default action for this signal when it is not handled.
*/
action: SignalAction
/**
* Whether the signal's default action cannot be prevented.
* This is true for SIGTERM, SIGKILL and SIGSTOP.
*/
forced: boolean
/**
* Which standard defined that signal.
*/
standard: SignalStandard
}
/**
* Object whose keys are signal names and values are signal objects.
*/
export declare const signalsByName: { [signalName: SignalName]: Signal }
/**
* Object whose keys are signal numbers and values are signal objects.
*/
export declare const signalsByNumber: { [signalNumber: SignalNumber]: Signal }

View file

@ -1,26 +1,27 @@
{ {
"name": "human-signals", "name": "human-signals",
"version": "2.1.0", "version": "4.3.0",
"main": "build/src/main.js", "type": "module",
"exports": {
"types": "./build/types/main.d.ts",
"default": "./build/src/main.js"
},
"main": "./build/src/main.js",
"types": "./build/types/main.d.ts",
"files": [ "files": [
"build/src", "build/src/**/*.{js,json}",
"!~" "build/types/**/*.d.ts"
], ],
"sideEffects": false,
"scripts": { "scripts": {
"test": "gulp test" "test": "gulp test"
}, },
"husky": {
"hooks": {
"pre-push": "gulp check --full"
}
},
"description": "Human-friendly process signals", "description": "Human-friendly process signals",
"keywords": [ "keywords": [
"signal", "signal",
"signals", "signals",
"handlers", "handlers",
"error-handling", "error-handling",
"errors",
"interrupts", "interrupts",
"sigterm", "sigterm",
"sigint", "sigint",
@ -32,13 +33,14 @@
"operating-system", "operating-system",
"es6", "es6",
"javascript", "javascript",
"typescript",
"linux", "linux",
"macos", "macos",
"windows", "windows",
"nodejs" "nodejs"
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"homepage": "https://git.io/JeluP", "homepage": "https://www.github.com/ehmicky/human-signals",
"repository": "ehmicky/human-signals", "repository": "ehmicky/human-signals",
"bugs": { "bugs": {
"url": "https://github.com/ehmicky/human-signals/issues" "url": "https://github.com/ehmicky/human-signals/issues"
@ -48,17 +50,12 @@
"lib": "src", "lib": "src",
"test": "test" "test": "test"
}, },
"types": "build/src/main.d.ts",
"dependencies": {},
"devDependencies": { "devDependencies": {
"@ehmicky/dev-tasks": "^0.31.9", "@ehmicky/dev-tasks": "^1.0.102",
"ajv": "^6.12.0", "ajv": "^8.11.0",
"ava": "^3.5.0", "test-each": "^5.5.0"
"gulp": "^4.0.2",
"husky": "^4.2.3",
"test-each": "^2.0.0"
}, },
"engines": { "engines": {
"node": ">=10.17.0" "node": ">=14.18.0"
} }
} }

128
node_modules/is-stream/index.d.ts generated vendored
View file

@ -1,79 +1,81 @@
import * as stream from 'stream'; import {
Stream,
Writable as WritableStream,
Readable as ReadableStream,
Duplex as DuplexStream,
Transform as TransformStream,
} from 'node:stream';
declare const isStream: { /**
/** @returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
@returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
@example @example
``` ```
import * as fs from 'fs'; import fs from 'node:fs';
import isStream = require('is-stream'); import {isStream} from 'is-stream';
isStream(fs.createReadStream('unicorn.png')); isStream(fs.createReadStream('unicorn.png'));
//=> true //=> true
isStream({}); isStream({});
//=> false //=> false
``` ```
*/ */
(stream: unknown): stream is stream.Stream; export function isStream(stream: unknown): stream is Stream;
/** /**
@returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable). @returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable).
@example @example
``` ```
import * as fs from 'fs'; import fs from 'node:fs';
import isStream = require('is-stream'); import {isWritableStream} from 'is-stream';
isStream.writable(fs.createWriteStrem('unicorn.txt')); isWritableStream(fs.createWriteStrem('unicorn.txt'));
//=> true //=> true
``` ```
*/ */
writable(stream: unknown): stream is stream.Writable; export function isWritableStream(stream: unknown): stream is WritableStream;
/** /**
@returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable). @returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable).
@example @example
``` ```
import * as fs from 'fs'; import fs from 'node:fs';
import isStream = require('is-stream'); import {isReadableStream} from 'is-stream';
isStream.readable(fs.createReadStream('unicorn.png')); isReadableStream(fs.createReadStream('unicorn.png'));
//=> true //=> true
``` ```
*/ */
readable(stream: unknown): stream is stream.Readable; export function isReadableStream(stream: unknown): stream is ReadableStream;
/** /**
@returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex). @returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
@example @example
``` ```
import {Duplex} from 'stream'; import {Duplex as DuplexStream} from 'node:stream';
import isStream = require('is-stream'); import {isDuplexStream} from 'is-stream';
isStream.duplex(new Duplex()); isDuplexStream(new DuplexStream());
//=> true //=> true
``` ```
*/ */
duplex(stream: unknown): stream is stream.Duplex; export function isDuplexStream(stream: unknown): stream is DuplexStream;
/** /**
@returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform). @returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).
@example @example
``` ```
import * as fs from 'fs'; import fs from 'node:fs';
import Stringify = require('streaming-json-stringify'); import StringifyStream from 'streaming-json-stringify';
import isStream = require('is-stream'); import {isTransformStream} from 'is-stream';
isStream.transform(Stringify()); isTransformStream(StringifyStream());
//=> true //=> true
``` ```
*/ */
transform(input: unknown): input is stream.Transform; export function isTransformStream(stream: unknown): stream is TransformStream;
};
export = isStream;

49
node_modules/is-stream/index.js generated vendored
View file

@ -1,28 +1,29 @@
'use strict'; export function isStream(stream) {
return stream !== null
&& typeof stream === 'object'
&& typeof stream.pipe === 'function';
}
const isStream = stream => export function isWritableStream(stream) {
stream !== null && return isStream(stream)
typeof stream === 'object' && && stream.writable !== false
typeof stream.pipe === 'function'; && typeof stream._write === 'function'
&& typeof stream._writableState === 'object';
}
isStream.writable = stream => export function isReadableStream(stream) {
isStream(stream) && return isStream(stream)
stream.writable !== false && && stream.readable !== false
typeof stream._write === 'function' && && typeof stream._read === 'function'
typeof stream._writableState === 'object'; && typeof stream._readableState === 'object';
}
isStream.readable = stream => export function isDuplexStream(stream) {
isStream(stream) && return isWritableStream(stream)
stream.readable !== false && && isReadableStream(stream);
typeof stream._read === 'function' && }
typeof stream._readableState === 'object';
isStream.duplex = stream => export function isTransformStream(stream) {
isStream.writable(stream) && return isDuplexStream(stream)
isStream.readable(stream); && typeof stream._transform === 'function';
}
isStream.transform = stream =>
isStream.duplex(stream) &&
typeof stream._transform === 'function';
module.exports = isStream;

16
node_modules/is-stream/package.json generated vendored
View file

@ -1,6 +1,6 @@
{ {
"name": "is-stream", "name": "is-stream",
"version": "2.0.1", "version": "3.0.0",
"description": "Check if something is a Node.js stream", "description": "Check if something is a Node.js stream",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/is-stream", "repository": "sindresorhus/is-stream",
@ -10,8 +10,10 @@
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}, },
"scripts": { "scripts": {
"test": "xo && ava && tsd" "test": "xo && ava && tsd"
@ -33,10 +35,10 @@
"is" "is"
], ],
"devDependencies": { "devDependencies": {
"@types/node": "^11.13.6", "@types/node": "^16.4.13",
"ava": "^1.4.1", "ava": "^3.15.0",
"tempy": "^0.3.0", "tempy": "^1.0.1",
"tsd": "^0.7.2", "tsd": "^0.17.0",
"xo": "^0.24.0" "xo": "^0.44.0"
} }
} }

12
node_modules/is-stream/readme.md generated vendored
View file

@ -11,8 +11,8 @@ $ npm install is-stream
## Usage ## Usage
```js ```js
const fs = require('fs'); import fs from 'node:fs';
const isStream = require('is-stream'); import {isStream} from 'is-stream';
isStream(fs.createReadStream('unicorn.png')); isStream(fs.createReadStream('unicorn.png'));
//=> true //=> true
@ -27,19 +27,19 @@ isStream({});
Returns a `boolean` for whether it's a [`Stream`](https://nodejs.org/api/stream.html#stream_stream). Returns a `boolean` for whether it's a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
#### isStream.writable(stream) #### isWritableStream(stream)
Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable). Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable).
#### isStream.readable(stream) #### isReadableStream(stream)
Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable). Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable).
#### isStream.duplex(stream) #### isDuplexStream(stream)
Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex). Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### isStream.transform(stream) #### isTransformStream(stream)
Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform). Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).

View file

@ -1,52 +0,0 @@
export interface Options {
/**
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
@default false
*/
readonly ignoreNonConfigurable?: boolean;
}
/**
Modifies the `to` function to mimic the `from` function. Returns the `to` function.
`name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.
`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.
@param to - Mimicking function.
@param from - Function to mimic.
@returns The modified `to` function.
@example
```
import mimicFunction from 'mimic-fn';
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFunction(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
```
*/
export default function mimicFunction<
ArgumentsType extends unknown[],
ReturnType,
FunctionType extends (...arguments: ArgumentsType) => ReturnType
>(
to: (...arguments: ArgumentsType) => ReturnType,
from: FunctionType,
options?: Options,
): FunctionType;

View file

@ -1,71 +0,0 @@
const copyProperty = (to, from, property, ignoreNonConfigurable) => {
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
// `Function#prototype` is non-writable and non-configurable so can never be modified.
if (property === 'length' || property === 'prototype') {
return;
}
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
if (property === 'arguments' || property === 'caller') {
return;
}
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
return;
}
Object.defineProperty(to, property, fromDescriptor);
};
// `Object.defineProperty()` throws if the property exists, is not configurable and either:
// - one its descriptors is changed
// - it is non-writable and its value is changed
const canCopyProperty = function (toDescriptor, fromDescriptor) {
return toDescriptor === undefined || toDescriptor.configurable || (
toDescriptor.writable === fromDescriptor.writable &&
toDescriptor.enumerable === fromDescriptor.enumerable &&
toDescriptor.configurable === fromDescriptor.configurable &&
(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)
);
};
const changePrototype = (to, from) => {
const fromPrototype = Object.getPrototypeOf(from);
if (fromPrototype === Object.getPrototypeOf(to)) {
return;
}
Object.setPrototypeOf(to, fromPrototype);
};
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
// We use `bind()` instead of a closure for the same reason.
// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
const changeToString = (to, from, name) => {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
Object.defineProperty(newToString, 'name', toStringName);
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
};
export default function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
const {name} = to;
for (const property of Reflect.ownKeys(from)) {
copyProperty(to, from, property, ignoreNonConfigurable);
}
changePrototype(to, from);
changeToString(to, from, name);
return to;
}

View file

@ -1,90 +0,0 @@
<img src="media/logo.svg" alt="mimic-fn" width="400">
<br>
> Make a function mimic another one
Useful when you wrap a function in another function and like to preserve the original name and other properties.
## Install
```
$ npm install mimic-fn
```
## Usage
```js
import mimicFunction from 'mimic-fn';
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFunction(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
console.log(String(wrapper));
//=> '/* Wrapped with wrapper() */\nfunction foo() {}'
```
## API
### mimicFunction(to, from, options?)
Modifies the `to` function to mimic the `from` function. Returns the `to` function.
`name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.
`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.
#### to
Type: `Function`
Mimicking function.
#### from
Type: `Function`
Function to mimic.
#### options
Type: `object`
##### ignoreNonConfigurable
Type: `boolean`\
Default: `false`
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
## Related
- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function
- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name and other properties
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-mimic-fn?utm_source=npm-mimic-fn&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

96
node_modules/mimic-fn/index.d.ts generated vendored
View file

@ -1,54 +1,52 @@
declare const mimicFn: { export interface Options {
/** /**
Make a function mimic another one. It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set. Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
@param to - Mimicking function. @default false
@param from - Function to mimic.
@returns The modified `to` function.
@example
```
import mimicFn = require('mimic-fn');
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFn(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
```
*/ */
< readonly ignoreNonConfigurable?: boolean;
ArgumentsType extends unknown[], }
ReturnType,
FunctionType extends (...arguments: ArgumentsType) => ReturnType
>(
to: (...arguments: ArgumentsType) => ReturnType,
from: FunctionType
): FunctionType;
// TODO: Remove this for the next major release, refactor the whole definition to: /**
// declare function mimicFn< Modifies the `to` function to mimic the `from` function. Returns the `to` function.
// ArgumentsType extends unknown[],
// ReturnType,
// FunctionType extends (...arguments: ArgumentsType) => ReturnType
// >(
// to: (...arguments: ArgumentsType) => ReturnType,
// from: FunctionType
// ): FunctionType;
// export = mimicFn;
default: typeof mimicFn;
};
export = mimicFn; `name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.
`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.
@param to - Mimicking function.
@param from - Function to mimic.
@returns The modified `to` function.
@example
```
import mimicFunction from 'mimic-fn';
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFunction(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
```
*/
export default function mimicFunction<
ArgumentsType extends unknown[],
ReturnType,
FunctionType extends (...arguments: ArgumentsType) => ReturnType
>(
to: (...arguments: ArgumentsType) => ReturnType,
from: FunctionType,
options?: Options,
): FunctionType;

76
node_modules/mimic-fn/index.js generated vendored
View file

@ -1,13 +1,71 @@
'use strict'; const copyProperty = (to, from, property, ignoreNonConfigurable) => {
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
const mimicFn = (to, from) => { // `Function#prototype` is non-writable and non-configurable so can never be modified.
for (const prop of Reflect.ownKeys(from)) { if (property === 'length' || property === 'prototype') {
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop)); return;
} }
return to; // `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
if (property === 'arguments' || property === 'caller') {
return;
}
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
return;
}
Object.defineProperty(to, property, fromDescriptor);
}; };
module.exports = mimicFn; // `Object.defineProperty()` throws if the property exists, is not configurable and either:
// TODO: Remove this for the next major release // - one its descriptors is changed
module.exports.default = mimicFn; // - it is non-writable and its value is changed
const canCopyProperty = function (toDescriptor, fromDescriptor) {
return toDescriptor === undefined || toDescriptor.configurable || (
toDescriptor.writable === fromDescriptor.writable &&
toDescriptor.enumerable === fromDescriptor.enumerable &&
toDescriptor.configurable === fromDescriptor.configurable &&
(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)
);
};
const changePrototype = (to, from) => {
const fromPrototype = Object.getPrototypeOf(from);
if (fromPrototype === Object.getPrototypeOf(to)) {
return;
}
Object.setPrototypeOf(to, fromPrototype);
};
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
// We use `bind()` instead of a closure for the same reason.
// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
const changeToString = (to, from, name) => {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
Object.defineProperty(newToString, 'name', toStringName);
Object.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});
};
export default function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
const {name} = to;
for (const property of Reflect.ownKeys(from)) {
copyProperty(to, from, property, ignoreNonConfigurable);
}
changePrototype(to, from);
changeToString(to, from, name);
return to;
}

2
node_modules/mimic-fn/license generated vendored
View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

15
node_modules/mimic-fn/package.json generated vendored
View file

@ -1,16 +1,19 @@
{ {
"name": "mimic-fn", "name": "mimic-fn",
"version": "2.1.0", "version": "4.0.0",
"description": "Make a function mimic another one", "description": "Make a function mimic another one",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/mimic-fn", "repository": "sindresorhus/mimic-fn",
"funding": "https://github.com/sponsors/sindresorhus",
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=6" "node": ">=12"
}, },
"scripts": { "scripts": {
"test": "xo && ava && tsd" "test": "xo && ava && tsd"
@ -35,8 +38,8 @@
"change" "change"
], ],
"devDependencies": { "devDependencies": {
"ava": "^1.4.1", "ava": "^3.15.0",
"tsd": "^0.7.1", "tsd": "^0.14.0",
"xo": "^0.24.0" "xo": "^0.38.2"
} }
} }

45
node_modules/mimic-fn/readme.md generated vendored
View file

@ -1,21 +1,20 @@
# mimic-fn [![Build Status](https://travis-ci.org/sindresorhus/mimic-fn.svg?branch=master)](https://travis-ci.org/sindresorhus/mimic-fn) <img src="media/logo.svg" alt="mimic-fn" width="400">
<br>
> Make a function mimic another one > Make a function mimic another one
Useful when you wrap a function in another function and like to preserve the original name and other properties. Useful when you wrap a function in another function and like to preserve the original name and other properties.
## Install ## Install
``` ```
$ npm install mimic-fn $ npm install mimic-fn
``` ```
## Usage ## Usage
```js ```js
const mimicFn = require('mimic-fn'); import mimicFunction from 'mimic-fn';
function foo() {} function foo() {}
foo.unicorn = '🦄'; foo.unicorn = '🦄';
@ -27,23 +26,28 @@ function wrapper() {
console.log(wrapper.name); console.log(wrapper.name);
//=> 'wrapper' //=> 'wrapper'
mimicFn(wrapper, foo); mimicFunction(wrapper, foo);
console.log(wrapper.name); console.log(wrapper.name);
//=> 'foo' //=> 'foo'
console.log(wrapper.unicorn); console.log(wrapper.unicorn);
//=> '🦄' //=> '🦄'
console.log(String(wrapper));
//=> '/* Wrapped with wrapper() */\nfunction foo() {}'
``` ```
## API ## API
It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set. ### mimicFunction(to, from, options?)
### mimicFn(to, from) Modifies the `to` function to mimic the `from` function. Returns the `to` function.
Modifies the `to` function and returns it. `name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.
`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.
#### to #### to
@ -57,13 +61,30 @@ Type: `Function`
Function to mimic. Function to mimic.
#### options
Type: `object`
##### ignoreNonConfigurable
Type: `boolean`\
Default: `false`
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
## Related ## Related
- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function - [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function
- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name, length and other properties - [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name and other properties
---
## License <div align="center">
<b>
MIT © [Sindre Sorhus](https://sindresorhus.com) <a href="https://tidelift.com/subscription/pkg/npm-mimic-fn?utm_source=npm-mimic-fn&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

141
node_modules/npm-run-path/index.d.ts generated vendored
View file

@ -1,89 +1,84 @@
declare namespace npmRunPath { export interface RunPathOptions {
interface RunPathOptions { /**
/** Working directory.
Working directory.
@default process.cwd() @default process.cwd()
*/ */
readonly cwd?: string; readonly cwd?: string | URL;
/** /**
PATH to be appended. Default: [`PATH`](https://github.com/sindresorhus/path-key). PATH to be appended. Default: [`PATH`](https://github.com/sindresorhus/path-key).
Set it to an empty string to exclude the default PATH. Set it to an empty string to exclude the default PATH.
*/ */
readonly path?: string; readonly path?: string;
/** /**
Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH. Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH.
This can be either an absolute path or a path relative to the `cwd` option. This can be either an absolute path or a path relative to the `cwd` option.
@default process.execPath @default process.execPath
*/ */
readonly execPath?: string; readonly execPath?: string;
}
interface ProcessEnv {
[key: string]: string | undefined;
}
interface EnvOptions {
/**
Working directory.
@default process.cwd()
*/
readonly cwd?: string;
/**
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
*/
readonly env?: ProcessEnv;
/**
Path to the current Node.js executable. Its directory is pushed to the front of PATH.
This can be either an absolute path or a path relative to the `cwd` option.
@default process.execPath
*/
readonly execPath?: string;
}
} }
declare const npmRunPath: { export type ProcessEnv = Record<string, string | undefined>;
export interface EnvOptions {
/** /**
Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries. The working directory.
@returns The augmented path string. @default process.cwd()
@example
```
import * as childProcess from 'child_process';
import npmRunPath = require('npm-run-path');
console.log(process.env.PATH);
//=> '/usr/local/bin'
console.log(npmRunPath());
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
// `foo` is a locally installed binary
childProcess.execFileSync('foo', {
env: npmRunPath.env()
});
```
*/ */
(options?: npmRunPath.RunPathOptions): string; readonly cwd?: string | URL;
/** /**
@returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object. Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
*/ */
env(options?: npmRunPath.EnvOptions): npmRunPath.ProcessEnv; readonly env?: ProcessEnv;
// TODO: Remove this for the next major release /**
default: typeof npmRunPath; The path to the current Node.js executable. Its directory is pushed to the front of PATH.
};
export = npmRunPath; This can be either an absolute path or a path relative to the `cwd` option.
@default process.execPath
*/
readonly execPath?: string;
}
/**
Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
@returns The augmented path string.
@example
```
import childProcess from 'node:child_process';
import {npmRunPath} from 'npm-run-path';
console.log(process.env.PATH);
//=> '/usr/local/bin'
console.log(npmRunPath());
//=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
```
*/
export function npmRunPath(options?: RunPathOptions): string;
/**
@returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
@example
```
import childProcess from 'node:child_process';
import {npmRunPathEnv} from 'npm-run-path';
// `foo` is a locally installed binary
childProcess.execFileSync('foo', {
env: npmRunPathEnv()
});
```
*/
export function npmRunPathEnv(options?: EnvOptions): ProcessEnv;

49
node_modules/npm-run-path/index.js generated vendored
View file

@ -1,17 +1,18 @@
'use strict'; import process from 'node:process';
const path = require('path'); import path from 'node:path';
const pathKey = require('path-key'); import url from 'node:url';
import pathKey from 'path-key';
const npmRunPath = options => { export function npmRunPath(options = {}) {
options = { const {
cwd: process.cwd(), cwd = process.cwd(),
path: process.env[pathKey()], path: path_ = process.env[pathKey()],
execPath: process.execPath, execPath = process.execPath,
...options } = options;
};
let previous; let previous;
let cwdPath = path.resolve(options.cwd); const cwdString = cwd instanceof URL ? url.fileURLToPath(cwd) : cwd;
let cwdPath = path.resolve(cwdString);
const result = []; const result = [];
while (previous !== cwdPath) { while (previous !== cwdPath) {
@ -20,28 +21,18 @@ const npmRunPath = options => {
cwdPath = path.resolve(cwdPath, '..'); cwdPath = path.resolve(cwdPath, '..');
} }
// Ensure the running `node` binary is used // Ensure the running `node` binary is used.
const execPathDir = path.resolve(options.cwd, options.execPath, '..'); result.push(path.resolve(cwdString, execPath, '..'));
result.push(execPathDir);
return result.concat(options.path).join(path.delimiter); return [...result, path_].join(path.delimiter);
}; }
module.exports = npmRunPath; export function npmRunPathEnv({env = process.env, ...options} = {}) {
// TODO: Remove this for the next major release env = {...env};
module.exports.default = npmRunPath;
module.exports.env = options => {
options = {
env: process.env,
...options
};
const env = {...options.env};
const path = pathKey({env}); const path = pathKey({env});
options.path = env[path]; options.path = env[path];
env[path] = module.exports(options); env[path] = npmRunPath(options);
return env; return env;
}; }

2
node_modules/npm-run-path/license generated vendored
View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -0,0 +1,31 @@
export interface Options {
/**
Use a custom environment variables object.
Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env).
*/
readonly env?: Record<string, string | undefined>;
/**
Get the PATH key for a specific platform.
Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform).
*/
readonly platform?: NodeJS.Platform;
}
/**
Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform.
@example
```
import pathKey from 'path-key';
const key = pathKey();
//=> 'PATH'
const PATH = process.env[key];
//=> '/usr/local/bin:/usr/bin:/bin'
```
*/
export default function pathKey(options?: Options): string;

View file

@ -0,0 +1,12 @@
export default function pathKey(options = {}) {
const {
env = process.env,
platform = process.platform
} = options;
if (platform !== 'win32') {
return 'PATH';
}
return Object.keys(env).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
}

View file

@ -1,9 +1,9 @@
{ {
"name": "mimic-fn", "name": "path-key",
"version": "4.0.0", "version": "4.0.0",
"description": "Make a function mimic another one", "description": "Get the PATH environment variable key cross-platform",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/mimic-fn", "repository": "sindresorhus/path-key",
"funding": "https://github.com/sponsors/sindresorhus", "funding": "https://github.com/sponsors/sindresorhus",
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
@ -23,21 +23,17 @@
"index.d.ts" "index.d.ts"
], ],
"keywords": [ "keywords": [
"function", "path",
"mimic", "key",
"imitate", "environment",
"rename", "env",
"copy", "variable",
"inherit", "get",
"properties", "cross-platform",
"name", "windows"
"func",
"fn",
"set",
"infer",
"change"
], ],
"devDependencies": { "devDependencies": {
"@types/node": "^14.14.37",
"ava": "^3.15.0", "ava": "^3.15.0",
"tsd": "^0.14.0", "tsd": "^0.14.0",
"xo": "^0.38.2" "xo": "^0.38.2"

View file

@ -0,0 +1,57 @@
# path-key
> Get the [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable key cross-platform
It's usually `PATH` but on Windows it can be any casing like `Path`...
## Install
```
$ npm install path-key
```
## Usage
```js
import pathKey from 'path-key';
const key = pathKey();
//=> 'PATH'
const PATH = process.env[key];
//=> '/usr/local/bin:/usr/bin:/bin'
```
## API
### pathKey(options?)
#### options
Type: `object`
##### env
Type: `object`\
Default: [`process.env`](https://nodejs.org/api/process.html#process_process_env)
Use a custom environment variables object.
#### platform
Type: `string`\
Default: [`process.platform`](https://nodejs.org/api/process.html#process_process_platform)
Get the PATH key for a specific platform.
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-path-key?utm_source=npm-path-key&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

View file

@ -1,16 +1,19 @@
{ {
"name": "npm-run-path", "name": "npm-run-path",
"version": "4.0.1", "version": "5.1.0",
"description": "Get your PATH prepended with locally installed binaries", "description": "Get your PATH prepended with locally installed binaries",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/npm-run-path", "repository": "sindresorhus/npm-run-path",
"funding": "https://github.com/sponsors/sindresorhus",
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}, },
"scripts": { "scripts": {
"test": "xo && ava && tsd" "test": "xo && ava && tsd"
@ -34,11 +37,11 @@
"executable" "executable"
], ],
"dependencies": { "dependencies": {
"path-key": "^3.0.0" "path-key": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^1.4.1", "ava": "^3.15.0",
"tsd": "^0.7.2", "tsd": "^0.17.0",
"xo": "^0.24.0" "xo": "^0.45.0"
} }
} }

44
node_modules/npm-run-path/readme.md generated vendored
View file

@ -1,22 +1,20 @@
# npm-run-path [![Build Status](https://travis-ci.org/sindresorhus/npm-run-path.svg?branch=master)](https://travis-ci.org/sindresorhus/npm-run-path) # npm-run-path
> Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries > Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries
In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm. In [npm run scripts](https://docs.npmjs.com/cli/run-script) you can execute locally installed binaries by name. This enables the same outside npm.
## Install ## Install
```sh
npm install npm-run-path
``` ```
$ npm install npm-run-path
```
## Usage ## Usage
```js ```js
const childProcess = require('child_process'); import childProcess from 'node:child_process';
const npmRunPath = require('npm-run-path'); import {npmRunPath, npmRunPathEnv} from 'npm-run-path';
console.log(process.env.PATH); console.log(process.env.PATH);
//=> '/usr/local/bin' //=> '/usr/local/bin'
@ -26,16 +24,15 @@ console.log(npmRunPath());
// `foo` is a locally installed binary // `foo` is a locally installed binary
childProcess.execFileSync('foo', { childProcess.execFileSync('foo', {
env: npmRunPath.env() env: npmRunPathEnv()
}); });
``` ```
## API ## API
### npmRunPath(options?) ### npmRunPath(options?)
Returns the augmented path string. Returns the augmented PATH string.
#### options #### options
@ -43,29 +40,30 @@ Type: `object`
##### cwd ##### cwd
Type: `string`<br> Type: `string | URL`\
Default: `process.cwd()` Default: `process.cwd()`
Working directory. The working directory.
##### path ##### path
Type: `string`<br> Type: `string`\
Default: [`PATH`](https://github.com/sindresorhus/path-key) Default: [`PATH`](https://github.com/sindresorhus/path-key)
PATH to be appended.<br> The PATH to be appended.
Set it to an empty string to exclude the default PATH. Set it to an empty string to exclude the default PATH.
##### execPath ##### execPath
Type: `string`<br> Type: `string`\
Default: `process.execPath` Default: `process.execPath`
Path to the current Node.js executable. Its directory is pushed to the front of PATH. The path to the current Node.js executable. Its directory is pushed to the front of PATH.
This can be either an absolute path or a path relative to the [`cwd` option](#cwd). This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
### npmRunPath.env(options?) ### npmRunPathEnv(options?)
Returns the augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object. Returns the augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
@ -75,33 +73,31 @@ Type: `object`
##### cwd ##### cwd
Type: `string`<br> Type: `string | URL`\
Default: `process.cwd()` Default: `process.cwd()`
Working directory. The working directory.
##### env ##### env
Type: `Object` Type: `object`
Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options. Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options.
##### execPath ##### execPath
Type: `string`<br> Type: `string`\
Default: `process.execPath` Default: `process.execPath`
Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH. The path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH.
This can be either an absolute path or a path relative to the [`cwd` option](#cwd). This can be either an absolute path or a path relative to the [`cwd` option](#cwd).
## Related ## Related
- [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module - [npm-run-path-cli](https://github.com/sindresorhus/npm-run-path-cli) - CLI for this module
- [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary - [execa](https://github.com/sindresorhus/execa) - Execute a locally installed binary
--- ---
<div align="center"> <div align="center">

29
node_modules/onetime/index.d.ts generated vendored
View file

@ -1,12 +1,10 @@
declare namespace onetime { export interface Options {
interface Options { /**
/** Throw an error when called more than once.
Throw an error when called more than once.
@default false @default false
*/ */
throw?: boolean; readonly throw?: boolean;
}
} }
declare const onetime: { declare const onetime: {
@ -18,11 +16,11 @@ declare const onetime: {
@example @example
``` ```
import onetime = require('onetime'); import onetime from 'onetime';
let i = 0; let index = 0;
const foo = onetime(() => ++i); const foo = onetime(() => ++index);
foo(); //=> 1 foo(); //=> 1
foo(); //=> 1 foo(); //=> 1
@ -33,7 +31,7 @@ declare const onetime: {
*/ */
<ArgumentsType extends unknown[], ReturnType>( <ArgumentsType extends unknown[], ReturnType>(
fn: (...arguments: ArgumentsType) => ReturnType, fn: (...arguments: ArgumentsType) => ReturnType,
options?: onetime.Options options?: Options
): (...arguments: ArgumentsType) => ReturnType; ): (...arguments: ArgumentsType) => ReturnType;
/** /**
@ -44,7 +42,7 @@ declare const onetime: {
@example @example
``` ```
import onetime = require('onetime'); import onetime from 'onetime';
const foo = onetime(() => {}); const foo = onetime(() => {});
foo(); foo();
@ -56,9 +54,6 @@ declare const onetime: {
``` ```
*/ */
callCount(fn: (...arguments: any[]) => unknown): number; callCount(fn: (...arguments: any[]) => unknown): number;
// TODO: Remove this for the next major release
default: typeof onetime;
}; };
export = onetime; export default onetime;

13
node_modules/onetime/index.js generated vendored
View file

@ -1,5 +1,4 @@
'use strict'; import mimicFunction from 'mimic-fn';
const mimicFn = require('mimic-fn');
const calledFunctions = new WeakMap(); const calledFunctions = new WeakMap();
@ -25,20 +24,18 @@ const onetime = (function_, options = {}) => {
return returnValue; return returnValue;
}; };
mimicFn(onetime, function_); mimicFunction(onetime, function_);
calledFunctions.set(onetime, callCount); calledFunctions.set(onetime, callCount);
return onetime; return onetime;
}; };
module.exports = onetime; onetime.callCount = function_ => {
// TODO: Remove this for the next major release
module.exports.default = onetime;
module.exports.callCount = function_ => {
if (!calledFunctions.has(function_)) { if (!calledFunctions.has(function_)) {
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
} }
return calledFunctions.get(function_); return calledFunctions.get(function_);
}; };
export default onetime;

14
node_modules/onetime/package.json generated vendored
View file

@ -1,6 +1,6 @@
{ {
"name": "onetime", "name": "onetime",
"version": "5.1.2", "version": "6.0.0",
"description": "Ensure a function is only called once", "description": "Ensure a function is only called once",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/onetime", "repository": "sindresorhus/onetime",
@ -10,8 +10,10 @@
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=6" "node": ">=12"
}, },
"scripts": { "scripts": {
"test": "xo && ava && tsd" "test": "xo && ava && tsd"
@ -33,11 +35,11 @@
"prevent" "prevent"
], ],
"dependencies": { "dependencies": {
"mimic-fn": "^2.1.0" "mimic-fn": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^1.4.1", "ava": "^3.15.0",
"tsd": "^0.7.1", "tsd": "^0.14.0",
"xo": "^0.24.0" "xo": "^0.38.2"
} }
} }

12
node_modules/onetime/readme.md generated vendored
View file

@ -1,4 +1,4 @@
# onetime [![Build Status](https://travis-ci.com/sindresorhus/onetime.svg?branch=master)](https://travis-ci.com/github/sindresorhus/onetime) # onetime
> Ensure a function is only called once > Ensure a function is only called once
@ -15,11 +15,11 @@ $ npm install onetime
## Usage ## Usage
```js ```js
const onetime = require('onetime'); import onetime from 'onetime';
let i = 0; let index = 0;
const foo = onetime(() => ++i); const foo = onetime(() => ++index);
foo(); //=> 1 foo(); //=> 1
foo(); //=> 1 foo(); //=> 1
@ -29,7 +29,7 @@ onetime.callCount(foo); //=> 3
``` ```
```js ```js
const onetime = require('onetime'); import onetime from 'onetime';
const foo = onetime(() => {}, {throw: true}); const foo = onetime(() => {}, {throw: true});
@ -69,7 +69,7 @@ Returns a number representing how many times `fn` has been called.
Note: It throws an error if you pass in a function that is not wrapped by `onetime`. Note: It throws an error if you pass in a function that is not wrapped by `onetime`.
```js ```js
const onetime = require('onetime'); import onetime from 'onetime';
const foo = onetime(() => {}); const foo = onetime(() => {});

View file

@ -1,16 +1,14 @@
'use strict'; export default function stripFinalNewline(input) {
module.exports = input => {
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt(); const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt(); const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
if (input[input.length - 1] === LF) { if (input[input.length - 1] === LF) {
input = input.slice(0, input.length - 1); input = input.slice(0, -1);
} }
if (input[input.length - 1] === CR) { if (input[input.length - 1] === CR) {
input = input.slice(0, input.length - 1); input = input.slice(0, -1);
} }
return input; return input;
}; }

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,16 +1,19 @@
{ {
"name": "strip-final-newline", "name": "strip-final-newline",
"version": "2.0.0", "version": "3.0.0",
"description": "Strip the final newline character from a string/buffer", "description": "Strip the final newline character from a string/buffer",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/strip-final-newline", "repository": "sindresorhus/strip-final-newline",
"funding": "https://github.com/sponsors/sindresorhus",
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "sindresorhus.com" "url": "https://sindresorhus.com"
}, },
"type": "module",
"exports": "./index.js",
"engines": { "engines": {
"node": ">=6" "node": ">=12"
}, },
"scripts": { "scripts": {
"test": "xo && ava" "test": "xo && ava"
@ -34,7 +37,7 @@
"buffer" "buffer"
], ],
"devDependencies": { "devDependencies": {
"ava": "^0.25.0", "ava": "^3.15.0",
"xo": "^0.23.0" "xo": "^0.39.1"
} }
} }

View file

@ -1,21 +1,19 @@
# strip-final-newline [![Build Status](https://travis-ci.com/sindresorhus/strip-final-newline.svg?branch=master)](https://travis-ci.com/sindresorhus/strip-final-newline) # strip-final-newline
> Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from a string/buffer > Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from a string/buffer
Can be useful when parsing the output of, for example, `ChildProcess#execFile`, as [binaries usually output a newline at the end](https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline). Normally, you would use `stdout.trim()`, but that would also remove newlines at the start and whitespace. Can be useful when parsing the output of, for example, `ChildProcess#execFile`, as [binaries usually output a newline at the end](https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline). Normally, you would use `stdout.trim()`, but that would also remove newlines at the start and whitespace.
## Install ## Install
``` ```
$ npm install strip-final-newline $ npm install strip-final-newline
``` ```
## Usage ## Usage
```js ```js
const stripFinalNewline = require('strip-final-newline'); import stripFinalNewline from 'strip-final-newline';
stripFinalNewline('foo\nbar\n\n'); stripFinalNewline('foo\nbar\n\n');
//=> 'foo\nbar\n' //=> 'foo\nbar\n'
@ -24,7 +22,14 @@ stripFinalNewline(Buffer.from('foo\nbar\n\n')).toString();
//=> 'foo\nbar\n' //=> 'foo\nbar\n'
``` ```
---
## License <div align="center">
<b>
MIT © [Sindre Sorhus](https://sindresorhus.com) <a href="https://tidelift.com/subscription/pkg/npm-strip-eof?utm_source=npm-strip-eof&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

142
package-lock.json generated
View file

@ -40,7 +40,7 @@
"zlib": "^1.0.5" "zlib": "^1.0.5"
}, },
"devDependencies": { "devDependencies": {
"@ava/typescript": "3.0.1", "@ava/typescript": "4.0.0",
"@types/adm-zip": "^0.5.0", "@types/adm-zip": "^0.5.0",
"@types/get-folder-size": "^2.0.0", "@types/get-folder-size": "^2.0.0",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
@ -201,16 +201,16 @@
} }
}, },
"node_modules/@ava/typescript": { "node_modules/@ava/typescript": {
"version": "3.0.1", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-3.0.1.tgz", "resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-4.0.0.tgz",
"integrity": "sha512-/JXIUuKsvkaneaiA9ckk3ksFTqvu0mDNlChASrTe2BnDsvMbhQdPWyqQjJ9WRJWVhhs5TWn1/0Pp1G6Rv8Syrw==", "integrity": "sha512-QFIPeqkEbdvn7Pob0wVeYpeZD0eXd8nDYdCl+knJVaIJrHdF2fXa58vFaig26cmYwnsEN0KRNTYJKbqW1B0lfg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"escape-string-regexp": "^5.0.0", "escape-string-regexp": "^5.0.0",
"execa": "^5.1.1" "execa": "^7.1.0"
}, },
"engines": { "engines": {
"node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17" "node": ">=14.19 <15 || >=16.15 <17 || >=18"
} }
}, },
"node_modules/@ava/typescript/node_modules/escape-string-regexp": { "node_modules/@ava/typescript/node_modules/escape-string-regexp": {
@ -3102,40 +3102,28 @@
} }
}, },
"node_modules/execa": { "node_modules/execa": {
"version": "5.1.1", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", "resolved": "https://registry.npmjs.org/execa/-/execa-7.1.0.tgz",
"integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", "integrity": "sha512-T6nIJO3LHxUZ6ahVRaxXz9WLEruXLqdcluA+UuTptXmLM7nDAn9lx9IfkxPyzEL21583qSt4RmL44pO71EHaJQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"get-stream": "^6.0.0", "get-stream": "^6.0.1",
"human-signals": "^2.1.0", "human-signals": "^4.3.0",
"is-stream": "^2.0.0", "is-stream": "^3.0.0",
"merge-stream": "^2.0.0", "merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1", "npm-run-path": "^5.1.0",
"onetime": "^5.1.2", "onetime": "^6.0.0",
"signal-exit": "^3.0.3", "signal-exit": "^3.0.7",
"strip-final-newline": "^2.0.0" "strip-final-newline": "^3.0.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": "^14.18.0 || ^16.14.0 || >=18.0.0"
}, },
"funding": { "funding": {
"url": "https://github.com/sindresorhus/execa?sponsor=1" "url": "https://github.com/sindresorhus/execa?sponsor=1"
} }
}, },
"node_modules/execa/node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/fast-deep-equal": { "node_modules/fast-deep-equal": {
"version": "3.1.3", "version": "3.1.3",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
@ -3387,6 +3375,18 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/get-symbol-description": { "node_modules/get-symbol-description": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
@ -3619,12 +3619,12 @@
} }
}, },
"node_modules/human-signals": { "node_modules/human-signals": {
"version": "2.1.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.0.tgz",
"integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "integrity": "sha512-zyzVyMjpGBX2+6cDVZeFPCdtOtdsxOeseRhB9tkQ6xXmGUNrcnBzdEKPy3VPNYz+4gy1oukVOXcrJCunSyc6QQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=10.17.0" "node": ">=14.18.0"
} }
}, },
"node_modules/ignore": { "node_modules/ignore": {
@ -3998,12 +3998,12 @@
} }
}, },
"node_modules/is-stream": { "node_modules/is-stream": {
"version": "2.0.1", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
@ -4400,18 +4400,6 @@
"url": "https://github.com/sindresorhus/mem?sponsor=1" "url": "https://github.com/sindresorhus/mem?sponsor=1"
} }
}, },
"node_modules/mem/node_modules/mimic-fn": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/merge-stream": { "node_modules/merge-stream": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@ -4458,11 +4446,15 @@
} }
}, },
"node_modules/mimic-fn": { "node_modules/mimic-fn": {
"version": "2.1.0", "version": "4.0.0",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
@ -4599,15 +4591,30 @@
} }
}, },
"node_modules/npm-run-path": { "node_modules/npm-run-path": {
"version": "4.0.1", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz",
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"path-key": "^3.0.0" "path-key": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">=8" "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/npm-run-path/node_modules/path-key": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
"integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/object-inspect": { "node_modules/object-inspect": {
@ -4718,15 +4725,15 @@
} }
}, },
"node_modules/onetime": { "node_modules/onetime": {
"version": "5.1.2", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"mimic-fn": "^2.1.0" "mimic-fn": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">=6" "node": ">=12"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
@ -5563,12 +5570,15 @@
} }
}, },
"node_modules/strip-final-newline": { "node_modules/strip-final-newline": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/strip-json-comments": { "node_modules/strip-json-comments": {

View file

@ -55,7 +55,7 @@
"micromatch is an unspecified dependency of ava" "micromatch is an unspecified dependency of ava"
], ],
"devDependencies": { "devDependencies": {
"@ava/typescript": "3.0.1", "@ava/typescript": "4.0.0",
"@types/adm-zip": "^0.5.0", "@types/adm-zip": "^0.5.0",
"@types/get-folder-size": "^2.0.0", "@types/get-folder-size": "^2.0.0",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",