Comparing version 1.1.0 to 1.1.1
@@ -12,2 +12,6 @@ # Changelog | ||
## [1.1.1] - 2020-12-30 | ||
- Improve error message when a value is not stringable. | ||
## [1.1.0] - 2020-12-22 | ||
@@ -14,0 +18,0 @@ |
{ | ||
"name": "shescape", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "simple shell escape library", | ||
@@ -5,0 +5,0 @@ "homepage": "https://ericcornelissen.github.io/shescape/", |
@@ -0,1 +1,3 @@ | ||
module.exports.typeError = | ||
"Shescape requires strings or values that can be converted into a string using .toString()"; | ||
module.exports.win32 = "win32"; |
@@ -1,7 +0,23 @@ | ||
const { win32 } = require("./constants.js"); | ||
const { typeError, win32 } = require("./constants.js"); | ||
const unix = require("./unix.js"); | ||
const win = require("./win.js"); | ||
function isStringable(value) { | ||
if (value === undefined || value === null) { | ||
return false; | ||
} | ||
return typeof value.toString === "function"; | ||
} | ||
function escapeShellArgByPlatform(arg, platform) { | ||
const argAsString = arg.toString(); | ||
let argAsString = arg; | ||
if (typeof arg !== "string") { | ||
if (!isStringable(arg)) { | ||
throw new TypeError(typeError); | ||
} | ||
argAsString = arg.toString(); | ||
} | ||
switch (platform) { | ||
@@ -8,0 +24,0 @@ case win32: |
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
24355
76