Socket
Socket
Sign inDemoInstall

cmd-shim

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmd-shim - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

87

index.js

@@ -84,29 +84,12 @@ // On windows, create a .cmd file.

// @SETLOCAL
// @CALL :find_dp0
//
// @IF EXIST "%dp0%\node.exe" (
// @SET "_prog=%dp0%\node.exe"
// ) ELSE (
// @SET "_prog=node"
// @SET PATHEXT=%PATHEXT:;.JS;=;%
// )
//
// "%_prog%" "%dp0%\.\node_modules\npm\bin\npm-cli.js" %*
// @ENDLOCAL
// @EXIT /b %errorlevel%
//
// :find_dp0
// SET dp0=%~dp0
// EXIT /b
//
// Subroutine trick to fix https://github.com/npm/cmd-shim/issues/10
// and https://github.com/npm/cli/issues/969
const head = '@ECHO off\r\n' +
'GOTO start\r\n' +
':find_dp0\r\n' +
'SET dp0=%~dp0\r\n' +
'EXIT /b\r\n' +
':start\r\n' +
'SETLOCAL\r\n' +
'CALL :find_dp0\r\n'
const foot = 'ENDLOCAL\r\n' +
'EXIT /b %errorlevel%\r\n' +
':find_dp0\r\n' +
'SET dp0=%~dp0\r\n' +
'EXIT /b\r\n'

@@ -128,6 +111,8 @@ let cmd

+ '\r\n'
// prevent "Terminate Batch Job? (Y/n)" message
// https://github.com/npm/cli/issues/969#issuecomment-737496588
+ 'endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & '
+ `"%_prog%" ${args} ${target} %*\r\n`
+ foot
} else {
cmd = `${head}${prog} ${args} ${target} %*\r\n${foot}`
cmd = `${head}${prog} ${args} ${target} %*\r\n`
}

@@ -143,9 +128,6 @@

// if [ -x "$basedir/node.exe" ]; then
// "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
// ret=$?
// exec "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
// else
// node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
// ret=$?
// exec node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
// fi
// exit $ret

@@ -165,13 +147,9 @@ let sh = "#!/bin/sh\n"

+ `if [ -x ${shLongProg} ]; then\n`
+ ` ${variables}${shLongProg} ${args} ${shTarget} "$@"\n`
+ ' ret=$?\n'
+ ` exec ${variables}${shLongProg} ${args} ${shTarget} "$@"\n`
+ 'else \n'
+ ` ${variables}${shProg} ${args} ${shTarget} "$@"\n`
+ ' ret=$?\n'
+ ` exec ${variables}${shProg} ${args} ${shTarget} "$@"\n`
+ 'fi\n'
+ 'exit $ret\n'
} else {
sh = sh
+ `${shProg} ${args} ${shTarget} "$@"\n`
+ 'exit $?\n'
+ `exec ${shProg} ${args} ${shTarget} "$@"\n`
}

@@ -190,6 +168,16 @@

// if (Test-Path "$basedir/node") {
// & "$basedir/node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// # Suport pipeline input
// if ($MyInvocation.ExpectingInput) {
// input | & "$basedir/node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// } else {
// & "$basedir/node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// }
// $ret=$LASTEXITCODE
// } else {
// & "node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// # Support pipeline input
// if ($MyInvocation.ExpectingInput) {
// $input | & "node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// } else {
// & "node$exe" "$basedir/node_modules/npm/bin/npm-cli.js" $args
// }
// $ret=$LASTEXITCODE

@@ -211,6 +199,16 @@ // }

+ `if (Test-Path ${pwshLongProg}) {\n`
+ ` & ${pwshLongProg} ${args} ${shTarget} $args\n`
+ ' # Support pipeline input\n'
+ ' if ($MyInvocation.ExpectingInput) {\n'
+ ` $input | & ${pwshLongProg} ${args} ${shTarget} $args\n`
+ ' } else {\n'
+ ` & ${pwshLongProg} ${args} ${shTarget} $args\n`
+ ' }\n'
+ ' $ret=$LASTEXITCODE\n'
+ '} else {\n'
+ ` & ${pwshProg} ${args} ${shTarget} $args\n`
+ ' # Support pipeline input\n'
+ ' if ($MyInvocation.ExpectingInput) {\n'
+ ` $input | & ${pwshProg} ${args} ${shTarget} $args\n`
+ ' } else {\n'
+ ` & ${pwshProg} ${args} ${shTarget} $args\n`
+ ' }\n'
+ ' $ret=$LASTEXITCODE\n'

@@ -221,3 +219,8 @@ + '}\n'

pwsh = pwsh
+ `& ${pwshProg} ${args} ${shTarget} $args\n`
+ '# Support pipeline input\n'
+ 'if ($MyInvocation.ExpectingInput) {\n'
+ ` $input | & ${pwshProg} ${args} ${shTarget} $args\n`
+ '} else {\n'
+ ` & ${pwshProg} ${args} ${shTarget} $args\n`
+ '}\n'
+ 'exit $LASTEXITCODE\n'

@@ -224,0 +227,0 @@ }

{
"name": "cmd-shim",
"version": "4.0.2",
"version": "4.1.0",
"description": "Used in npm for command line application support",

@@ -18,3 +18,2 @@ "scripts": {

"dependencies": {
"graceful-fs": "^4.1.2",
"mkdirp-infer-owner": "^2.0.0"

@@ -21,0 +20,0 @@ },

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