Comparing version 1.5.3 to 1.5.4
@@ -12,2 +12,7 @@ # Changelog | ||
## [1.5.4] - 2022-03-07 | ||
- Fix `Cannot find module 'path/win32'` error on Node.js <16.0.0. ([#199]) | ||
- Improve detection of the Windows operating system. ([#192]) | ||
## [1.5.3] - 2022-03-06 | ||
@@ -126,3 +131,5 @@ | ||
[#190]: https://github.com/ericcornelissen/shescape/pull/190 | ||
[#192]: https://github.com/ericcornelissen/shescape/pull/192 | ||
[#199]: https://github.com/ericcornelissen/shescape/pull/199 | ||
[keep a changelog]: https://keepachangelog.com/en/1.0.0/ | ||
[semantic versioning]: https://semver.org/spec/v2.0.0.html |
@@ -11,3 +11,3 @@ /** | ||
* @module shescape | ||
* @version 1.5.3 | ||
* @version 1.5.4 | ||
* @license MPL-2.0 | ||
@@ -30,3 +30,3 @@ * @author Eric Cornelissen <ericornelissen@gmail.com> | ||
const platform = os.platform(); | ||
const helpers = getHelpersByPlatform(platform); | ||
const helpers = getHelpersByPlatform({ platform, process }); | ||
return helpers; | ||
@@ -33,0 +33,0 @@ } |
{ | ||
"name": "shescape", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "simple shell escape library", | ||
@@ -63,3 +63,3 @@ "homepage": "https://ericcornelissen.github.io/shescape/", | ||
"prettier": "2.5.1", | ||
"rollup": "2.69.0", | ||
"rollup": "2.70.0", | ||
"sinon": "13.0.1" | ||
@@ -66,0 +66,0 @@ }, |
@@ -11,2 +11,12 @@ /** | ||
/** | ||
* @constant {string} cygwin The string identifying the OS type cygwin. | ||
*/ | ||
const cygwin = "cygwin"; | ||
/** | ||
* @constant {string} msys The string identifying the OS type msys. | ||
*/ | ||
const msys = "msys"; | ||
/** | ||
* @constant {string} win32 The string identifying Windows systems. | ||
@@ -17,14 +27,33 @@ */ | ||
/** | ||
* Check if the current platform is Windows. | ||
* | ||
* @param {Object} args The arguments for this function. | ||
* @param {string} args.platform The `os.platform()` value. | ||
* @param {Object} args.process The `process` values. | ||
* @param {Object} args.process.env The environment variables. | ||
* @returns {boolean} `true` iff the current platform is Windows. | ||
*/ | ||
function isWindow({ platform, process }) { | ||
return ( | ||
platform === win32 || | ||
process.env.OSTYPE === cygwin || | ||
process.env.OSTYPE === msys | ||
); | ||
} | ||
/** | ||
* Get all helper functions for a specific platform. | ||
* | ||
* @param {string} platform The platform to get the helpers for. | ||
* @returns {Object} The helper functions for `platform`. | ||
* @param {Object} args The arguments for this function. | ||
* @param {string} args.platform The `os.platform()` value. | ||
* @param {Object} args.process The `process` values. | ||
* @param {Object} args.process.env The environment variables. | ||
* @returns {Object} The helper functions for the current platform. | ||
*/ | ||
export function getHelpersByPlatform(platform) { | ||
switch (platform) { | ||
case win32: | ||
return win; | ||
default: | ||
return unix; | ||
export function getHelpersByPlatform(args) { | ||
if (isWindow(args)) { | ||
return win; | ||
} | ||
return unix; | ||
} |
@@ -8,3 +8,3 @@ /** | ||
import * as fs from "fs"; | ||
import * as path from "path/win32"; | ||
import * as path from "path"; | ||
import which from "which"; | ||
@@ -106,3 +106,3 @@ | ||
function getBasename(fullPath) { | ||
return path.basename(fullPath); | ||
return path.win32.basename(fullPath); | ||
} | ||
@@ -109,0 +109,0 @@ |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
80309
1359
9