Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zkochan/cmd-shim

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zkochan/cmd-shim - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

54

index.js

@@ -22,2 +22,4 @@ 'use strict'

const DEFAULT_OPTIONS = {
// Create PowerShell file by default if the option hasn't been specified
createPwshFile: true,
createCmdFile: isWindows()

@@ -55,3 +57,3 @@ }

function writeShim (src, to, opts) {
opts = opts || {}
opts = Object.assign({}, DEFAULT_OPTIONS, opts)
const defaultArgs = opts.preserveSymlinks ? '--preserve-symlinks' : ''

@@ -78,5 +80,3 @@ // make a cmd file and a sh script

function writeShim_ (src, to, opts) {
opts = opts || {}
// Create PowerShell file by default if the option hasn't been specified
opts.createPwshFile = (typeof opts.createPwshFile !== 'undefined' ? opts.createPwshFile : true)
opts = Object.assign({}, DEFAULT_OPTIONS, opts)
let shTarget = path.relative(path.dirname(to), src)

@@ -92,2 +92,6 @@ let target = shTarget.split('/').join('\\')

let args = opts.args || ''
let {
win32: nodePath,
posix: shNodePath
} = normalizePathEnvVar(opts.nodePath)
if (!prog) {

@@ -117,3 +121,3 @@ prog = `"%~dp0\\${target}"`

// )
cmd = opts.nodePath ? `@SET NODE_PATH=${opts.nodePath}\r\n` : ''
cmd = nodePath ? `@SET NODE_PATH=${nodePath}\r\n` : ''
if (longProg) {

@@ -156,3 +160,3 @@ cmd += '@IF EXIST ' + longProg + ' (\r\n' +

'\n'
const env = opts.nodePath ? `NODE_PATH="${opts.nodePath}" ` : ''
const env = opts.nodePath ? `NODE_PATH="${shNodePath}" ` : ''

@@ -196,2 +200,4 @@ if (shLongProg) {

'$exe=""\n' +
(opts.nodePath ? '$env_node_path=$env:NODE_PATH\n' +
`$env:NODE_PATH="${nodePath}"\n` : '') +
'if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {\n' +

@@ -201,3 +207,10 @@ ' # Fix case when both the Windows and Linux builds of Node\n' +

' $exe=".exe"\n' +
'}\n'
'}'
if (opts.nodePath) {
pwsh = pwsh +
' else {\n' +
` $env:NODE_PATH="${shNodePath}"\n` +
'}'
}
pwsh += '\n'
if (shLongProg) {

@@ -213,2 +226,3 @@ pwsh = pwsh +

'}\n' +
(opts.nodePath ? '$env:NODE_PATH=$env_node_path\n' : '') +
'exit $ret\n'

@@ -218,2 +232,3 @@ } else {

`& ${pwshProg} ${args} ${shTarget} $args\n` +
(opts.nodePath ? '$env:NODE_PATH=$env_node_path\n' : '') +
'exit $LASTEXITCODE\n'

@@ -237,1 +252,26 @@ }

}
/**
* @param {string} nodePath
* @returns {{win32:string,posix:string}}
*/
function normalizePathEnvVar (nodePath) {
if (!nodePath) {
return {
win32: nodePath,
posix: nodePath
}
}
let split = (typeof nodePath === 'string' ? String(nodePath).split(path.delimiter) : Array.from(nodePath))
let result = {}
for (let i = 0; i < split.length; i++) {
const win32 = split[i].split('/').join('\\')
const posix = isWindows() ? split[i].split('\\').join('/').replace(/^([^:\\/]*):/, (_, $1) => `/mnt/${$1.toLowerCase()}`) : split[i]
result.win32 = result.win32 ? `${result.win32};${win32}` : win32
result.posix = result.posix ? `${result.posix}:${posix}` : posix
result[i] = {win32, posix}
}
return result
}

2

package.json
{
"name": "@zkochan/cmd-shim",
"version": "3.0.0",
"version": "3.0.1",
"description": "Used in pnpm for command line application support",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc