Skip to content

Does cmdShim() support sh / batch (cmd) / pwsh script as src? #10

@tats-u

Description

@tats-u

Related:

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 and create-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 when pwsh (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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions