pkg-ci
zeit/pkg gives you the awesome ability to package your node app in a single executable binary. But if you have tests, you need to run them before you package your binary. This is fine for local development, but what if you want to run tests within a CI/CD environment against a previously packaged binary (avoid npm install
perhaps)? pkg-ci
allows you to do this.
TL;DR
Got a binary generated with zeit/pkg and you want to run your tests instead of running your app?
CI_MODE=true ./app
Run the app as usual
CI_MODE=false
Install
npm install pkg-ci
Usage
Create an entry file for your app entry.js
(or whatever you want to call it). Require pkg-ci
and point it to your app's package.json
file
const path = path
When you run your pkg
build step, point it to entry.js
pkg entry.js --output ./out
Ensure your package.json
has the appropriate npm start
script defined
After you have compiled your binary, whenever your binary is run with CI_MODE=true
your app will not run, instead, your npm test
script will run. Anything else will run your app as usual.
Credits
License
MIT