Skip to content

Commit

Permalink
Deprecate calling shescape directly
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcornelissen committed Dec 7, 2020
1 parent f54b943 commit 15ccb78
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Versioning].

- _No changes yet_

## [0.3.1] - 2020-12-07

- Deprecate calling `shescape()` directly.

## [0.3.0] - 2020-12-07

- Add `escape` function to escape an argument (same as `shescape()`).
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const os = require("os");
const main = require("./src/main.js");

module.exports = function (arg) {
console.warn(
"calling shescape() directly is deprecated since v0.3.1 and will be removed in v1.0.0"
);
const platform = os.platform();
return main.escapeShellArgByPlatform(arg, platform);
};
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shescape",
"version": "0.3.0",
"version": "0.3.1",
"description": "simple shell escape library",
"homepage": "https://github.com/ericcornelissen/shescape#readme",
"license": "MPL-2.0",
Expand Down
9 changes: 9 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ describe("index.js", function () {
main.escapeShellArgByPlatform.restore();
});

it("informs about deprecation of calling shescape directly", function () {
sinon.spy(console, "warn");

shescape("foobar");
assert(console.warn.called);

console.warn.restore();
});

it("escape calls main for current OS", function () {
const osStubOutput = "MundOS";
sinon.stub(os, "platform").returns(osStubOutput);
Expand Down

0 comments on commit 15ccb78

Please sign in to comment.