Skip to content

wireit doesn't work with preinstall scripts #1344

@RJWadley

Description

@RJWadley

I'd like to use wireit for preinstall scripts:

"preinstall": "wireit",
"pnpm:devPreinstall": "wireit",

Obviously, what you can do in a preinstall script is fairly limited. packages won't be available, but you can still do scripting related stuff.

Using the usual configuration here will fail because wireit has not yet been installed:

. pnpm:devPreinstall$ wireit
│ sh: wireit: command not found
└─ Running...
 ELIFECYCLE  Command failed.
. preinstall$ wireit
│ sh: wireit: command not found
└─ Running...
 ELIFECYCLE  Command failed.

The obvious fix is to use pnpx or similar to ensure the package is downloaded:

"preinstall": "pnpx wireit",
"pnpm:devPreinstall": "pnpx wireit",

But wireit itself complains in that scenario:

. pnpm:devPreinstall$ pnpx wireit
│ ❌ package.json:16:25 This command should just be "wireit", as this script is configured in the wireit section.
│     ning...   "pnpm:devPreinstall": "pnpx wireit",
│                             ~~~~~~~~~~~~~
│     package.json:124:3 The wireit config is here.
│         ...           "pnpm:devPreinstall": {
│           ~~~~~~~~~~~~~~~~~~~~
└─ Failed in 404ms at /Users/robbie/programming/work/gen-1
 ELIFECYCLE  Command failed with exit code 1.

I'd suggest relaxing wireit's check here to allow invoking wireit via a package manager within it's script, eg:

npx wireit
bunx wireit
pnpx wireit
pnpm dlx wireit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions