watson/is-ci

Negative check is-not-ci?

Maxim-Mazurok opened this issue · 3 comments

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)

Turns out that doesn't work on CI though, because script returns exit code 1 and npm thinks that there's an error :(

you can do

{
    "postinstall": "is-ci || npm run blabla",
}

Indeed, that works. For some reason, I thought that || wasn't portable and wouldn't fly in cmd.exe... Thank you!