Negative check is-not-ci?
Maxim-Mazurok opened this issue · 3 comments
Maxim-Mazurok commented
I want to run some script only if it's not in CI.
I've used this:
{
"is-not-ci": "npx -y --package \"is-ci\" --call \"node -e \\\"process.exit(require(\\\\\\\"is-ci\\\\\\\") ? 1 : 0)\\\"\"",
"postinstall": "npm run is-not-ci && npm run blabla",
}
Is there any better option?
(needs to be cross-platform: Win and Linux)
Maxim-Mazurok commented
Turns out that doesn't work on CI though, because script returns exit code 1 and npm thinks that there's an error :(
sibiraj-s commented
you can do
{
"postinstall": "is-ci || npm run blabla",
}
Maxim-Mazurok commented
Indeed, that works. For some reason, I thought that ||
wasn't portable and wouldn't fly in cmd.exe
... Thank you!