@zkochan/cmd-shim
Advanced tools
Comparing version 4.2.1 to 4.3.0
@@ -30,2 +30,6 @@ declare namespace cmdShim { | ||
/** | ||
* The arguments to initialize the target process with, before the actual CLI arguments | ||
*/ | ||
progArgs?: string[]; | ||
/** | ||
* The value of the $NODE_PATH environment variable. | ||
@@ -32,0 +36,0 @@ * |
33
index.js
@@ -216,2 +216,3 @@ 'use strict'; | ||
} | ||
let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : ''; | ||
// @IF EXIST "%~dp0\node.exe" ( | ||
@@ -226,12 +227,12 @@ // "%~dp0\node.exe" "%~dp0\.\node_modules\npm\bin\npm-cli.js" %* | ||
if (longProg) { | ||
cmd += '@IF EXIST ' + longProg + ' (\r\n' + | ||
' ' + longProg + ' ' + args + ' ' + target + ' %*\r\n' + | ||
cmd += `@IF EXIST ${longProg} (\r\n` + | ||
` ${longProg} ${args} ${target} ${progArgs}%*\r\n` + | ||
') ELSE (\r\n' + | ||
' @SETLOCAL\r\n' + | ||
' @SET PATHEXT=%PATHEXT:;.JS;=;%\r\n' + | ||
' ' + prog + ' ' + args + ' ' + target + ' %*\r\n' + | ||
` ${prog} ${args} ${target} ${progArgs}%*\r\n` + | ||
')'; | ||
} | ||
else { | ||
cmd += `@${prog} ${args} ${target} %*\r\n`; | ||
cmd += `@${prog} ${args} ${target} ${progArgs}%*\r\n`; | ||
} | ||
@@ -266,2 +267,3 @@ return cmd; | ||
} | ||
let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : ''; | ||
// #!/bin/sh | ||
@@ -291,11 +293,11 @@ // basedir=`dirname "$0"` | ||
if (shLongProg) { | ||
sh = sh + env + | ||
'if [ -x ' + shLongProg + ' ]; then\n' + | ||
' exec ' + shLongProg + ' ' + args + ' ' + shTarget + ' "$@"\n' + | ||
sh += env + | ||
`if [ -x ${shLongProg} ]; then\n` + | ||
` exec ${shLongProg} ${args} ${shTarget} ${progArgs}"$@"\n` + | ||
'else \n' + | ||
' exec ' + shProg + ' ' + args + ' ' + shTarget + ' "$@"\n' + | ||
` exec ${shProg} ${args} ${shTarget} ${progArgs}"$@"\n` + | ||
'fi\n'; | ||
} | ||
else { | ||
sh = sh + env + shProg + ' ' + args + ' ' + shTarget + ' "$@"\n' + | ||
sh += `${env}${shProg} ${args} ${shTarget} ${progArgs}"$@"\n` + | ||
'exit $?\n'; | ||
@@ -334,2 +336,3 @@ } | ||
} | ||
let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : ''; | ||
// #!/usr/bin/env pwsh | ||
@@ -387,5 +390,5 @@ // $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent | ||
' if ($MyInvocation.ExpectingInput) {\n' + | ||
` $input | & ${pwshLongProg} ${args} ${shTarget} $args\n` + | ||
` $input | & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
' } else {\n' + | ||
` & ${pwshLongProg} ${args} ${shTarget} $args\n` + | ||
` & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
' }\n' + | ||
@@ -396,5 +399,5 @@ ' $ret=$LASTEXITCODE\n' + | ||
' if ($MyInvocation.ExpectingInput) {\n' + | ||
` $input | & ${pwshProg} ${args} ${shTarget} $args\n` + | ||
` $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
' } else {\n' + | ||
` & ${pwshProg} ${args} ${shTarget} $args\n` + | ||
` & ${pwshProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
' }\n' + | ||
@@ -410,5 +413,5 @@ ' $ret=$LASTEXITCODE\n' + | ||
'if ($MyInvocation.ExpectingInput) {\n' + | ||
` $input | & ${pwshProg} ${args} ${shTarget} $args\n` + | ||
` $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
'} else {\n' + | ||
` & ${pwshProg} ${args} ${shTarget} $args\n` + | ||
` & ${pwshProg} ${args} ${shTarget} ${progArgs}$args\n` + | ||
'}\n' + | ||
@@ -415,0 +418,0 @@ (opts.nodePath ? '$env:NODE_PATH=$env_node_path\n' : '') + |
{ | ||
"name": "@zkochan/cmd-shim", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "Used in pnpm for command line application support", | ||
@@ -36,3 +36,3 @@ "author": { | ||
"@types/node": "^12.7.2", | ||
"jest": "^24.9.0", | ||
"jest": "^25.1.0", | ||
"lodash": "^4.17.15", | ||
@@ -39,0 +39,0 @@ "memory-fs": "^0.4.1", |
@@ -40,2 +40,3 @@ # @zkochan/cmd-shim | ||
- `opts.createPwshFile` - _Boolean_ - is `true` by default. If true, creates a powershell file. | ||
- `opts.progArgs` - String - optional arguments that will be prepend to any CLI arguments | ||
@@ -42,0 +43,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
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
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
34100
512
51