Skip to content

Commit

Permalink
Add --build-only parameter to filter build outputs
Browse files Browse the repository at this point in the history
Also, don't generate test bundle by default, but provide
`npm run build-test` instead.
  • Loading branch information
twiss committed Feb 9, 2021
1 parent 6a3d04a commit c20b752
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
],
"scripts": {
"build": "rollup --config",
"build-test": "npm run build --build-only=test",
"prepare": "npm run build",
"test": "mocha --timeout 120000 test/unittests.js",
"start": "http-server",
"prebrowsertest": "npm run build-test",
"browsertest": "npm start -- -o test/unittests.html",
"coverage": "nyc npm test",
"lint": "eslint 'src/**/*.js' 'test/crypto/**/*.js'",
Expand Down
14 changes: 12 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const terserOptions = {
}
};

export default [
export default Object.assign([
{
input: 'src/index.js',
output: [
Expand Down Expand Up @@ -100,4 +100,14 @@ export default [
})
]
}
];
].filter(config => {
config.output = config.output.filter(output => {
return (output.file || output.dir + '/' + output.entryFileNames).includes(
process.env.npm_config_build_only || // E.g. `npm install --build-only=lightweight`.
'dist' // Don't build test bundle by default.
);
});
return config.output.length;
}), {
allow_empty: true // Fake option to trick rollup into accepting empty config array when filtered above.
});
1 change: 1 addition & 0 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ elif [ $OPENPGPJSTEST = "unit" ]; then
elif [ $OPENPGPJSTEST = "browserstack" ]; then
echo "Running OpenPGP.js browser unit tests on Browserstack."

npm run build-test
echo -n "Using config: "
echo "{\"browsers\": [$BROWSER], \"test_framework\": \"mocha\", \"test_path\": [\"test/unittests.html?ci=true${LIGHTWEIGHT+&lightweight=true&grep=lightweight}\"], \"timeout\": 1800, \"exit_with_fail\": true, \"project\": \"openpgpjs/${TRAVIS_EVENT_TYPE:-push}${LIGHTWEIGHT:+/lightweight}\"}" > browserstack.json
cat browserstack.json
Expand Down

0 comments on commit c20b752

Please sign in to comment.