google / google/wireit

wireit doesn't work with preinstall scripts

Open
#1,344 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.4k
Forks
128
Avg merge
4d 10h
Merged PRs (30d)
4

Description

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.