forked from npm/cmd-shim
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
Related:
- Globally installed binaries do not work in PowerShell after 1.13.0 yarnpkg/yarn#6902
- Installation Problem: [Windows Powershell run the global command of yarn] yarnpkg/yarn#6913
Yarn for Windows calls cmdShim()
with the following src
and to
when yarn global add create-react-app
is executed:
src |
to |
---|---|
[Yarn global folder]\node_modules\.bin\create-react-app (for sh) |
[prefix]\bin\create-react-app |
[Yarn global folder]\node_modules\.bin\create-react-app.cmd |
[prefix]\bin\create-react-app.cmd |
[Yarn global folder]\node_modules\.bin\create-react-app.ps1 |
[prefix]\bin\create-react-app.ps1 |
https://github.com/yarnpkg/yarn/blob/1af4c5f50c4c146a833c0c2b20d10be1f5a61803/src/cli/commands/global.js#L168
https://github.com/yarnpkg/yarn/blob/1af4c5f50c4c146a833c0c2b20d10be1f5a61803/src/cli/commands/global.js#L168
As the result, this module creates:
- Junk named
create-react-app.cmd
andcreate-react-app.ps1
, which looks like a batch or PowerShell script but in fact are sh scripts; They can't execute in CMD or PowerShell in spite of their extensions. - 4 scripts with strange names
create-react-app.{ps1,cmd}.{cmd,ps1}
; To make matters worse,create-react-app.ps1.*
can't be executed whenpwsh
(for .NET Core) is not installed.
This issue was suppressed in Yarn until this module suppored PowerShell shims because the following code of Yarn, which replace create-react-app.cmd
(junk sh script) with create-react-app.cmd.cmd
:
https://github.com/yarnpkg/yarn/blob/1af4c5f50c4c146a833c0c2b20d10be1f5a61803/src/cli/commands/global.js#L169-L171
Anyway, this module must:
- Sense that
src
is a shell (sh, CMD, or PowerShell) script (maybe created by this module). - Supress creating unwanted scripts.
- Create shims to PowerShell scripts that properly works even if
pwsh
is unavailable.