Skip to content

Commit ca8d79d

Browse files
committed
revert: .cmd fallback
1 parent 1ed6834 commit ca8d79d

3 files changed

Lines changed: 2 additions & 139 deletions

File tree

src/index.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,9 @@ function generateCmdShim (src: string, to: string, opts: InternalOptions): strin
391391
`
392392
}
393393
if (longProg) {
394-
const longProgCmd = `"%~dp0\\${opts.prog}${CMD_EXTENSION}"`
395394
cmd += `\
396395
@IF EXIST ${longProg} (\r
397396
${longProg} ${args} ${target} ${progArgs}%*\r
398-
) ELSE IF EXIST ${longProgCmd} (\r
399-
${longProgCmd} ${args} ${target} ${progArgs}%*\r
400397
) ELSE (\r
401398
@SET PATHEXT=%PATHEXT:;.JS;=;%\r
402399
${prog} ${args} ${target} ${progArgs}%*\r
@@ -613,7 +610,6 @@ $env:PATH="$prepend_path$pathsep$env:PATH"
613610
`
614611
}
615612
if (pwshLongProg) {
616-
const pwshLongProgCmd = `"$basedir/${opts.prog}${CMD_EXTENSION}"`
617613
pwsh += `
618614
$ret=0
619615
if (Test-Path ${pwshLongProg}) {
@@ -624,14 +620,6 @@ if (Test-Path ${pwshLongProg}) {
624620
& ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args
625621
}
626622
$ret=$LASTEXITCODE
627-
} elseif (Test-Path ${pwshLongProgCmd}) {
628-
# Support pipeline input
629-
if ($MyInvocation.ExpectingInput) {
630-
$input | & ${pwshLongProgCmd} ${args} ${shTarget} ${progArgs}$args
631-
} else {
632-
& ${pwshLongProgCmd} ${args} ${shTarget} ${progArgs}$args
633-
}
634-
$ret=$LASTEXITCODE
635623
} else {
636624
# Support pipeline input
637625
if ($MyInvocation.ExpectingInput) {

test/__snapshots__/test.js.snap

Lines changed: 1 addition & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ exports[`batch script bat.shim.cmd 1`] = `
2424
"@SETLOCAL
2525
@IF EXIST "%~dp0\\cmd.exe" (
2626
"%~dp0\\cmd.exe" /C "%~dp0\\src.bat" %*
27-
) ELSE IF EXIST "%~dp0\\cmd.cmd" (
28-
"%~dp0\\cmd.cmd" /C "%~dp0\\src.bat" %*
2927
) ELSE (
3028
@SET PATHEXT=%PATHEXT:;.JS;=;%
3129
cmd /C "%~dp0\\src.bat" %*
@@ -52,14 +50,6 @@ if (Test-Path "$basedir/cmd$exe") {
5250
& "$basedir/cmd$exe" /C "$basedir/src.bat" $args
5351
}
5452
$ret=$LASTEXITCODE
55-
} elseif (Test-Path "$basedir/cmd.cmd") {
56-
# Support pipeline input
57-
if ($MyInvocation.ExpectingInput) {
58-
$input | & "$basedir/cmd.cmd" /C "$basedir/src.bat" $args
59-
} else {
60-
& "$basedir/cmd.cmd" /C "$basedir/src.bat" $args
61-
}
62-
$ret=$LASTEXITCODE
6353
} else {
6454
# Support pipeline input
6555
if ($MyInvocation.ExpectingInput) {
@@ -140,8 +130,6 @@ exports[`env shebang env.shim.cmd 1`] = `
140130
"@SETLOCAL
141131
@IF EXIST "%~dp0\\node.exe" (
142132
"%~dp0\\node.exe" "%~dp0\\src.env" %*
143-
) ELSE IF EXIST "%~dp0\\node.cmd" (
144-
"%~dp0\\node.cmd" "%~dp0\\src.env" %*
145133
) ELSE (
146134
@SET PATHEXT=%PATHEXT:;.JS;=;%
147135
node "%~dp0\\src.env" %*
@@ -168,14 +156,6 @@ if (Test-Path "$basedir/node$exe") {
168156
& "$basedir/node$exe" "$basedir/src.env" $args
169157
}
170158
$ret=$LASTEXITCODE
171-
} elseif (Test-Path "$basedir/node.cmd") {
172-
# Support pipeline input
173-
if ($MyInvocation.ExpectingInput) {
174-
$input | & "$basedir/node.cmd" "$basedir/src.env" $args
175-
} else {
176-
& "$basedir/node.cmd" "$basedir/src.env" $args
177-
}
178-
$ret=$LASTEXITCODE
179159
} else {
180160
# Support pipeline input
181161
if ($MyInvocation.ExpectingInput) {
@@ -223,8 +203,6 @@ exports[`env shebang with NODE_PATH env.shim.cmd 1`] = `
223203
)
224204
@IF EXIST "%~dp0\\node.exe" (
225205
"%~dp0\\node.exe" "%~dp0\\src.env" %*
226-
) ELSE IF EXIST "%~dp0\\node.cmd" (
227-
"%~dp0\\node.cmd" "%~dp0\\src.env" %*
228206
) ELSE (
229207
@SET PATHEXT=%PATHEXT:;.JS;=;%
230208
node "%~dp0\\src.env" %*
@@ -263,14 +241,6 @@ if (Test-Path "$basedir/node$exe") {
263241
& "$basedir/node$exe" "$basedir/src.env" $args
264242
}
265243
$ret=$LASTEXITCODE
266-
} elseif (Test-Path "$basedir/node.cmd") {
267-
# Support pipeline input
268-
if ($MyInvocation.ExpectingInput) {
269-
$input | & "$basedir/node.cmd" "$basedir/src.env" $args
270-
} else {
271-
& "$basedir/node.cmd" "$basedir/src.env" $args
272-
}
273-
$ret=$LASTEXITCODE
274244
} else {
275245
# Support pipeline input
276246
if ($MyInvocation.ExpectingInput) {
@@ -311,8 +281,6 @@ exports[`env shebang with PATH extending env.shim.cmd 1`] = `
311281
@SET "PATH=\\add-to-path:%PATH%"
312282
@IF EXIST "%~dp0\\node.exe" (
313283
"%~dp0\\node.exe" "%~dp0\\src.env" %*
314-
) ELSE IF EXIST "%~dp0\\node.cmd" (
315-
"%~dp0\\node.cmd" "%~dp0\\src.env" %*
316284
) ELSE (
317285
@SET PATHEXT=%PATHEXT:;.JS;=;%
318286
node "%~dp0\\src.env" %*
@@ -348,14 +316,6 @@ if (Test-Path "$basedir/node$exe") {
348316
& "$basedir/node$exe" "$basedir/src.env" $args
349317
}
350318
$ret=$LASTEXITCODE
351-
} elseif (Test-Path "$basedir/node.cmd") {
352-
# Support pipeline input
353-
if ($MyInvocation.ExpectingInput) {
354-
$input | & "$basedir/node.cmd" "$basedir/src.env" $args
355-
} else {
356-
& "$basedir/node.cmd" "$basedir/src.env" $args
357-
}
358-
$ret=$LASTEXITCODE
359319
} else {
360320
# Support pipeline input
361321
if ($MyInvocation.ExpectingInput) {
@@ -394,8 +354,6 @@ exports[`env shebang with args env.args.shim.cmd 1`] = `
394354
"@SETLOCAL
395355
@IF EXIST "%~dp0\\node.exe" (
396356
"%~dp0\\node.exe" --expose_gc "%~dp0\\src.env.args" %*
397-
) ELSE IF EXIST "%~dp0\\node.cmd" (
398-
"%~dp0\\node.cmd" --expose_gc "%~dp0\\src.env.args" %*
399357
) ELSE (
400358
@SET PATHEXT=%PATHEXT:;.JS;=;%
401359
node --expose_gc "%~dp0\\src.env.args" %*
@@ -422,14 +380,6 @@ if (Test-Path "$basedir/node$exe") {
422380
& "$basedir/node$exe" --expose_gc "$basedir/src.env.args" $args
423381
}
424382
$ret=$LASTEXITCODE
425-
} elseif (Test-Path "$basedir/node.cmd") {
426-
# Support pipeline input
427-
if ($MyInvocation.ExpectingInput) {
428-
$input | & "$basedir/node.cmd" --expose_gc "$basedir/src.env.args" $args
429-
} else {
430-
& "$basedir/node.cmd" --expose_gc "$basedir/src.env.args" $args
431-
}
432-
$ret=$LASTEXITCODE
433383
} else {
434384
# Support pipeline input
435385
if ($MyInvocation.ExpectingInput) {
@@ -467,8 +417,6 @@ exports[`env shebang with default args env.shim.cmd 1`] = `
467417
"@SETLOCAL
468418
@IF EXIST "%~dp0\\node.exe" (
469419
"%~dp0\\node.exe" --preserve-symlinks "%~dp0\\src.env" %*
470-
) ELSE IF EXIST "%~dp0\\node.cmd" (
471-
"%~dp0\\node.cmd" --preserve-symlinks "%~dp0\\src.env" %*
472420
) ELSE (
473421
@SET PATHEXT=%PATHEXT:;.JS;=;%
474422
node --preserve-symlinks "%~dp0\\src.env" %*
@@ -495,14 +443,6 @@ if (Test-Path "$basedir/node$exe") {
495443
& "$basedir/node$exe" --preserve-symlinks "$basedir/src.env" $args
496444
}
497445
$ret=$LASTEXITCODE
498-
} elseif (Test-Path "$basedir/node.cmd") {
499-
# Support pipeline input
500-
if ($MyInvocation.ExpectingInput) {
501-
$input | & "$basedir/node.cmd" --preserve-symlinks "$basedir/src.env" $args
502-
} else {
503-
& "$basedir/node.cmd" --preserve-symlinks "$basedir/src.env" $args
504-
}
505-
$ret=$LASTEXITCODE
506446
} else {
507447
# Support pipeline input
508448
if ($MyInvocation.ExpectingInput) {
@@ -540,8 +480,6 @@ exports[`env shebang with no NODE_PATH env.shim.cmd 1`] = `
540480
"@SETLOCAL
541481
@IF EXIST "%~dp0\\node.exe" (
542482
"%~dp0\\node.exe" "%~dp0\\src.env" %*
543-
) ELSE IF EXIST "%~dp0\\node.cmd" (
544-
"%~dp0\\node.cmd" "%~dp0\\src.env" %*
545483
) ELSE (
546484
@SET PATHEXT=%PATHEXT:;.JS;=;%
547485
node "%~dp0\\src.env" %*
@@ -568,14 +506,6 @@ if (Test-Path "$basedir/node$exe") {
568506
& "$basedir/node$exe" "$basedir/src.env" $args
569507
}
570508
$ret=$LASTEXITCODE
571-
} elseif (Test-Path "$basedir/node.cmd") {
572-
# Support pipeline input
573-
if ($MyInvocation.ExpectingInput) {
574-
$input | & "$basedir/node.cmd" "$basedir/src.env" $args
575-
} else {
576-
& "$basedir/node.cmd" "$basedir/src.env" $args
577-
}
578-
$ret=$LASTEXITCODE
579509
} else {
580510
# Support pipeline input
581511
if ($MyInvocation.ExpectingInput) {
@@ -613,8 +543,6 @@ exports[`explicit shebang sh.shim.cmd 1`] = `
613543
"@SETLOCAL
614544
@IF EXIST "%~dp0\\/usr/bin/sh.exe" (
615545
"%~dp0\\/usr/bin/sh.exe" "%~dp0\\src.sh" %*
616-
) ELSE IF EXIST "%~dp0\\/usr/bin/sh.cmd" (
617-
"%~dp0\\/usr/bin/sh.cmd" "%~dp0\\src.sh" %*
618546
) ELSE (
619547
@SET PATHEXT=%PATHEXT:;.JS;=;%
620548
/usr/bin/sh "%~dp0\\src.sh" %*
@@ -641,14 +569,6 @@ if (Test-Path "$basedir//usr/bin/sh$exe") {
641569
& "$basedir//usr/bin/sh$exe" "$basedir/src.sh" $args
642570
}
643571
$ret=$LASTEXITCODE
644-
} elseif (Test-Path "$basedir//usr/bin/sh.cmd") {
645-
# Support pipeline input
646-
if ($MyInvocation.ExpectingInput) {
647-
$input | & "$basedir//usr/bin/sh.cmd" "$basedir/src.sh" $args
648-
} else {
649-
& "$basedir//usr/bin/sh.cmd" "$basedir/src.sh" $args
650-
}
651-
$ret=$LASTEXITCODE
652572
} else {
653573
# Support pipeline input
654574
if ($MyInvocation.ExpectingInput) {
@@ -686,8 +606,6 @@ exports[`explicit shebang with args sh.args.shim.cmd 1`] = `
686606
"@SETLOCAL
687607
@IF EXIST "%~dp0\\/usr/bin/sh.exe" (
688608
"%~dp0\\/usr/bin/sh.exe" -x "%~dp0\\src.sh.args" %*
689-
) ELSE IF EXIST "%~dp0\\/usr/bin/sh.cmd" (
690-
"%~dp0\\/usr/bin/sh.cmd" -x "%~dp0\\src.sh.args" %*
691609
) ELSE (
692610
@SET PATHEXT=%PATHEXT:;.JS;=;%
693611
/usr/bin/sh -x "%~dp0\\src.sh.args" %*
@@ -714,14 +632,6 @@ if (Test-Path "$basedir//usr/bin/sh$exe") {
714632
& "$basedir//usr/bin/sh$exe" -x "$basedir/src.sh.args" $args
715633
}
716634
$ret=$LASTEXITCODE
717-
} elseif (Test-Path "$basedir//usr/bin/sh.cmd") {
718-
# Support pipeline input
719-
if ($MyInvocation.ExpectingInput) {
720-
$input | & "$basedir//usr/bin/sh.cmd" -x "$basedir/src.sh.args" $args
721-
} else {
722-
& "$basedir//usr/bin/sh.cmd" -x "$basedir/src.sh.args" $args
723-
}
724-
$ret=$LASTEXITCODE
725635
} else {
726636
# Support pipeline input
727637
if ($MyInvocation.ExpectingInput) {
@@ -752,15 +662,12 @@ if [ -x "$basedir//usr/bin/sh" ]; then
752662
else
753663
exec /usr/bin/sh -x "J:/cmd-shim/fixtures/src.sh.args" "$@"
754664
fi
755-
"
756665
`;
757666

758-
exports[`explicit shebang with args, linking to another drive on Windows sh.args.shim.cmd 1`] = `
667+
exports[`explicit shebang with args, linking to another drive on Windows sh.args.shim.CMD 1`] = `
759668
"@SETLOCAL
760669
@IF EXIST "%~dp0\\/usr/bin/sh.exe" (
761670
"%~dp0\\/usr/bin/sh.exe" -x "J:\\cmd-shim\\fixtures\\src.sh.args" %*
762-
) ELSE IF EXIST "%~dp0\\/usr/bin/sh.cmd" (
763-
"%~dp0\\/usr/bin/sh.cmd" -x "J:\\cmd-shim\\fixtures\\src.sh.args" %*
764671
) ELSE (
765672
@SET PATHEXT=%PATHEXT:;.JS;=;%
766673
/usr/bin/sh -x "J:\\cmd-shim\\fixtures\\src.sh.args" %*
@@ -787,14 +694,6 @@ if (Test-Path "$basedir//usr/bin/sh$exe") {
787694
& "$basedir//usr/bin/sh$exe" -x "J:/cmd-shim/fixtures/src.sh.args" $args
788695
}
789696
$ret=$LASTEXITCODE
790-
} elseif (Test-Path "$basedir//usr/bin/sh.cmd") {
791-
# Support pipeline input
792-
if ($MyInvocation.ExpectingInput) {
793-
$input | & "$basedir//usr/bin/sh.cmd" -x "J:/cmd-shim/fixtures/src.sh.args" $args
794-
} else {
795-
& "$basedir//usr/bin/sh.cmd" -x "J:/cmd-shim/fixtures/src.sh.args" $args
796-
}
797-
$ret=$LASTEXITCODE
798697
} else {
799698
# Support pipeline input
800699
if ($MyInvocation.ExpectingInput) {
@@ -832,8 +731,6 @@ exports[`explicit shebang with prog args sh.args.shim.cmd 1`] = `
832731
"@SETLOCAL
833732
@IF EXIST "%~dp0\\/usr/bin/sh.exe" (
834733
"%~dp0\\/usr/bin/sh.exe" -x "%~dp0\\src.sh.args" hello %*
835-
) ELSE IF EXIST "%~dp0\\/usr/bin/sh.cmd" (
836-
"%~dp0\\/usr/bin/sh.cmd" -x "%~dp0\\src.sh.args" hello %*
837734
) ELSE (
838735
@SET PATHEXT=%PATHEXT:;.JS;=;%
839736
/usr/bin/sh -x "%~dp0\\src.sh.args" hello %*
@@ -860,14 +757,6 @@ if (Test-Path "$basedir//usr/bin/sh$exe") {
860757
& "$basedir//usr/bin/sh$exe" -x "$basedir/src.sh.args" hello $args
861758
}
862759
$ret=$LASTEXITCODE
863-
} elseif (Test-Path "$basedir//usr/bin/sh.cmd") {
864-
# Support pipeline input
865-
if ($MyInvocation.ExpectingInput) {
866-
$input | & "$basedir//usr/bin/sh.cmd" -x "$basedir/src.sh.args" hello $args
867-
} else {
868-
& "$basedir//usr/bin/sh.cmd" -x "$basedir/src.sh.args" hello $args
869-
}
870-
$ret=$LASTEXITCODE
871760
} else {
872761
# Support pipeline input
873762
if ($MyInvocation.ExpectingInput) {
@@ -985,8 +874,6 @@ exports[`shebang with -S from.env.s.shim.cmd 1`] = `
985874
"@SETLOCAL
986875
@IF EXIST "%~dp0\\node.exe" (
987876
"%~dp0\\node.exe" --expose_gc "%~dp0\\from.env.S" %*
988-
) ELSE IF EXIST "%~dp0\\node.cmd" (
989-
"%~dp0\\node.cmd" --expose_gc "%~dp0\\from.env.S" %*
990877
) ELSE (
991878
@SET PATHEXT=%PATHEXT:;.JS;=;%
992879
node --expose_gc "%~dp0\\from.env.S" %*
@@ -1013,14 +900,6 @@ if (Test-Path "$basedir/node$exe") {
1013900
& "$basedir/node$exe" --expose_gc "$basedir/from.env.S" $args
1014901
}
1015902
$ret=$LASTEXITCODE
1016-
} elseif (Test-Path "$basedir/node.cmd") {
1017-
# Support pipeline input
1018-
if ($MyInvocation.ExpectingInput) {
1019-
$input | & "$basedir/node.cmd" --expose_gc "$basedir/from.env.S" $args
1020-
} else {
1021-
& "$basedir/node.cmd" --expose_gc "$basedir/from.env.S" $args
1022-
}
1023-
$ret=$LASTEXITCODE
1024903
} else {
1025904
# Support pipeline input
1026905
if ($MyInvocation.ExpectingInput) {

test/test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ const cmdShim = require('../')
1313
function testFile (fileName, lineEnding = '\n') {
1414
test(path.basename(fileName).toLowerCase(), async () => {
1515
const invalidLineEnding = lineEnding === '\r\n' ? /$(?<!\r)\n/ugm : /$\r\n/ugm
16-
let content = await fs.promises.readFile(fileName, 'utf8')
16+
const content = await fs.promises.readFile(fileName, 'utf8')
1717

1818
expect(content).not.toMatch(invalidLineEnding)
19-
// Normalize cmd extension casing for cross-platform snapshot consistency
20-
if (cmdExtension !== '.cmd') {
21-
content = content.replaceAll(cmdExtension, '.cmd')
22-
}
2319
expect(content).toMatchSnapshot()
2420
})
2521
}

0 commit comments

Comments
 (0)