## Problem - The Puppeteer `node_modules` directory is huge ## Solution - Delete the not needed content from `node_modules` - Inspired by [node-prune](https://github.com/tj/node-prune/) tool (written in Go, not much suitable to run during RPM build, I rewrote that to shell) ## Testing - Tested manually ## Numbers - The `node_modules` directory size went down from 39MB to 15MB (-62%) - The built RPM size went down from 3.5MB to 1.9MB (-46%) - I expect the Live ISO size reduction similar to the RPM reduction
34 lines
1.1 KiB
Bash
Executable file
34 lines
1.1 KiB
Bash
Executable file
#! /usr/bin/bash
|
|
|
|
# A helper script for running the Puppeteer integration tests.
|
|
#
|
|
# Usage:
|
|
# agama-integration-tests [mochajs-options] <path-to-test>
|
|
|
|
# exit on error, unset variables are an error
|
|
set -eu
|
|
|
|
MYDIR=$(realpath "$(dirname "$0")")
|
|
|
|
# options passed to mocha.js:
|
|
# --bail: stop at the first failure (otherwise the test would continue and very
|
|
# likely fail at the next steps as well, this prevents from false alarms)
|
|
# --slow: report tests as slow when they take more than 10 seconds, the default
|
|
# is 75ms which is too small for Agama
|
|
MOCHA_OPTIONS=(--bail --slow 10000)
|
|
|
|
if [ -e "$MYDIR/../.git/" ]; then
|
|
npm install --omit=optional
|
|
|
|
# do the same node_modules cleanup as in the RPM package to have the very same
|
|
# environment and have consistent results
|
|
"$MYDIR/node-prune.sh"
|
|
"$MYDIR/node-puppeteer-prune.sh"
|
|
|
|
npx mocha "${MOCHA_OPTIONS[@]}" "$@"
|
|
else
|
|
# set the default load path
|
|
export NODE_PATH=/usr/share/agama/integration-tests/node_modules
|
|
# run the CLI script directly, npm/npx might not be installed
|
|
/usr/bin/env node /usr/share/agama/integration-tests/node_modules/mocha/bin/mocha.js "${MOCHA_OPTIONS[@]}" "$@"
|
|
fi
|