Comparing version 2.0.2 to 2.1.0
@@ -14,2 +14,7 @@ <!-- SPDX-License-Identifier: CC0-1.0 --> | ||
## [2.1.0] - 2023-12-23 | ||
- Add `shescape/stateless` module with v1-like API. ([#1130]) | ||
- Re-export `Shescape` as `Stubscape` from `shescape/testing`. ([#1308]) | ||
## [2.0.2] - 2023-11-19 | ||
@@ -325,2 +330,3 @@ | ||
[#1094]: https://github.com/ericcornelissen/shescape/pull/1094 | ||
[#1130]: https://github.com/ericcornelissen/shescape/pull/1130 | ||
[#1137]: https://github.com/ericcornelissen/shescape/pull/1137 | ||
@@ -331,4 +337,5 @@ [#1142]: https://github.com/ericcornelissen/shescape/pull/1142 | ||
[#1285]: https://github.com/ericcornelissen/shescape/pull/1285 | ||
[#1308]: https://github.com/ericcornelissen/shescape/pull/1308 | ||
[552e8ea]: https://github.com/ericcornelissen/shescape/commit/552e8eab56861720b1d4e5474fb65741643358f9 | ||
[keep a changelog]: https://keepachangelog.com/en/1.0.0/ | ||
[semantic versioning]: https://semver.org/spec/v2.0.0.html |
@@ -21,15 +21,24 @@ <!-- SPDX-License-Identifier: CC-BY-SA-4.0 --> | ||
```javascript | ||
// my-module.test.js | ||
import assert from "node:assert"; | ||
import { Shescape as Stubscape, Throwscape } from "shescape/testing"; | ||
import { functionUnderTest } from "./my-module.js"; | ||
import { Stubscape, Throwscape } from "shescape/testing"; | ||
// Test good conditions | ||
const stubscape = new Stubscape(); | ||
assert.ok(functionUnderTest(stubscape)); | ||
// Test subject | ||
function functionUnderTest(Shescape) { | ||
const options = { | ||
/* ... */ | ||
}; | ||
const rawArgs = [ | ||
/*... */ | ||
]; | ||
// Test bad conditions | ||
const throwscape = new Throwscape(); | ||
assert.ok(functionUnderTest(throwscape)); | ||
const shescape = new Shescape(options); | ||
const args = shescape.escapeAll(rawArgs); | ||
return args; | ||
} | ||
// Test good condition | ||
assert.ok(functionUnderTest(Stubscape)); | ||
// Test bad condition | ||
assert.throws(() => functionUnderTest(Throwscape)); | ||
``` | ||
@@ -36,0 +45,0 @@ |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
interface ShescapeOptions { | ||
export interface ShescapeOptions { | ||
/** | ||
@@ -14,0 +14,0 @@ * Whether or not to protect against flag and option (such as `--verbose`) |
@@ -7,3 +7,3 @@ /** | ||
* @module shescape | ||
* @version 2.0.2 | ||
* @version 2.1.0 | ||
* @license MPL-2.0 | ||
@@ -10,0 +10,0 @@ */ |
{ | ||
"name": "shescape", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "simple shell escape library", | ||
@@ -19,2 +19,12 @@ "homepage": "https://github.com/ericcornelissen/shescape#readme", | ||
}, | ||
"./stateless": { | ||
"import": { | ||
"types": "./stateless.d.ts", | ||
"default": "./stateless.js" | ||
}, | ||
"require": { | ||
"types": "./stateless.d.cts", | ||
"default": "./stateless.cjs" | ||
} | ||
}, | ||
"./testing": { | ||
@@ -56,28 +66,29 @@ "import": { | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.13.0", | ||
"@arethetypeswrong/cli": "0.13.4", | ||
"@ericcornelissen/eslint-plugin-top": "2.1.0", | ||
"@fast-check/ava": "1.1.6", | ||
"@fast-check/ava": "1.2.1", | ||
"@gitlab-org/jsfuzz": "1.2.2", | ||
"@stryker-mutator/core": "7.3.0", | ||
"@stryker-mutator/tap-runner": "7.3.0", | ||
"ava": "5.3.1", | ||
"@stryker-mutator/core": "8.0.0", | ||
"@stryker-mutator/tap-runner": "8.0.0", | ||
"ava": "6.0.1", | ||
"better-npm-audit": "3.7.3", | ||
"c8": "8.0.1", | ||
"dotenv": "16.3.1", | ||
"eslint": "8.53.0", | ||
"eslint": "8.56.0", | ||
"eslint-plugin-ava": "14.0.0", | ||
"eslint-plugin-jsdoc": "46.9.0", | ||
"eslint-plugin-jsonc": "2.10.0", | ||
"eslint-plugin-regexp": "2.1.1", | ||
"eslint-plugin-yml": "1.10.0", | ||
"fast-check": "3.13.2", | ||
"eslint-plugin-jsonc": "2.11.2", | ||
"eslint-plugin-regexp": "2.1.2", | ||
"eslint-plugin-yml": "1.11.0", | ||
"fast-check": "3.15.0", | ||
"husky": "8.0.3", | ||
"is-ci": "3.0.1", | ||
"knip": "2.41.3", | ||
"knip": "3.8.4", | ||
"licensee": "10.0.0", | ||
"markdownlint-cli": "0.37.0", | ||
"lockfile-lint": "4.12.1", | ||
"markdownlint-cli": "0.38.0", | ||
"nve": "17.0.0", | ||
"prettier": "3.1.0", | ||
"prettier": "3.1.1", | ||
"publint": "0.2.4", | ||
"rollup": "4.4.0", | ||
"rollup": "4.9.1", | ||
"shescape-previous": "npm:shescape@2.0.1", | ||
@@ -87,11 +98,6 @@ "sinon": "17.0.1" | ||
"scripts": { | ||
"prefuzz": "npm run transpile", | ||
"prepare": "is-ci || husky install script/hooks", | ||
"prepublishOnly": "npm run transpile", | ||
"premutation:integration": "npm run transpile", | ||
"pretest:compat": "npm run transpile", | ||
"pretest:compat-all": "npm run transpile", | ||
"pretest:e2e": "npm run transpile", | ||
"pretest:integration": "npm run transpile", | ||
"prevet:deps": "npm run transpile", | ||
"prevet:package.json": "npm run transpile", | ||
@@ -129,4 +135,4 @@ "_eslint": "eslint . --config config/eslint.yml --report-unused-disable-directives", | ||
"test:breakage": "ava test/breakage/**/*.test.js", | ||
"test:compat": "ava test/compat/**/*.test.js", | ||
"test:compat-all": "nve 14.18.0,16.13.0,18.0.0,19.0.0,20.0.0 npm run test:compat --ignore-scripts", | ||
"test:compat": "node test/compat/runner.js", | ||
"test:compat-all": "nve 14.18.0,16.13.0,18.0.0,19.0.0,20.0.0 npm run test:compat", | ||
"test:e2e": "ava test/e2e/**/*.test.js --timeout 1m", | ||
@@ -137,6 +143,7 @@ "test:integration": "ava test/integration/**/*.test.js --timeout 2m", | ||
"verify": "npm run format:check && npm run license-check && npm run lint && npm run coverage && npm run vet", | ||
"vet": "npm run vet:deps && npm run vet:package.json", | ||
"vet": "npm run vet:deps && npm run vet:package.json && npm run vet:package-lock.json", | ||
"vet:deps": "knip --config config/knip.jsonc", | ||
"vet:package.json": "publint --strict && attw --pack ." | ||
"vet:package.json": "publint --strict && attw --pack .", | ||
"vet:package-lock.json": "lockfile-lint --path package-lock.json --allowed-hosts npm gitlab.com --validate-https" | ||
} | ||
} |
@@ -61,2 +61,6 @@ <!-- SPDX-License-Identifier: CC-BY-SA-4.0 --> | ||
### Migrating from v1 | ||
View the [migration] guidelines for help. | ||
### Recipes | ||
@@ -106,2 +110,3 @@ | ||
[license]: ./LICENSE | ||
[migration]: docs/migration.md | ||
[mit license]: https://opensource.org/license/mit/ | ||
@@ -108,0 +113,0 @@ [powershell]: https://en.wikipedia.org/wiki/PowerShell |
@@ -21,10 +21,27 @@ /** | ||
/** | ||
* A test stub of shescape that has the same input-output profile as the real | ||
* shescape implementation. | ||
* An optimistic test stub of Shescape that has the same input-output profile as | ||
* the real Shescape implementation. | ||
* | ||
* In particular: | ||
* - The constructor never fails. | ||
* - Returns a string for all stringable inputs. | ||
* - Errors on non-stringable inputs. | ||
* - Converts non-array inputs to single-item arrays where necessary. | ||
* - Errors on non-array inputs where arrays are expected. | ||
* - Errors when trying to quote when `shell: false`. | ||
*/ | ||
export const Stubscape: ShescapeType; | ||
/** | ||
* An optimistic test stub of Shescape that has the same input-output profile as | ||
* the real Shescape implementation. | ||
* | ||
* In particular: | ||
* - The constructor never fails. | ||
* - Returns a string for all stringable inputs. | ||
* - Errors on non-stringable inputs. | ||
* - Errors on non-array inputs where arrays are expected. | ||
* - Errors when trying to quote when `shell: false`. | ||
* | ||
* @alias Stubscape | ||
*/ | ||
export const Shescape: ShescapeType; | ||
@@ -31,0 +48,0 @@ |
@@ -39,3 +39,3 @@ /** | ||
*/ | ||
export class Shescape { | ||
export class Stubscape { | ||
constructor(options = {}) { | ||
@@ -67,2 +67,17 @@ this.shell = options.shell; | ||
/** | ||
* An optimistic test stub of Shescape that has the same input-output profile as | ||
* the real Shescape implementation. | ||
* | ||
* In particular: | ||
* - The constructor never fails. | ||
* - Returns a string for all stringable inputs. | ||
* - Errors on non-stringable inputs. | ||
* - Errors on non-array inputs where arrays are expected. | ||
* - Errors when trying to quote when `shell: false`. | ||
* | ||
* @alias Stubscape | ||
*/ | ||
export const Shescape = Stubscape; | ||
/** | ||
* A test stub of Shescape that can't be instantiated. This can be used to | ||
@@ -69,0 +84,0 @@ * simulate a failure to instantiate Shescape in your code. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218427
36
4624
119
29
6