forked from justeattakeaway/fozzie-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundlewatch.config.js
More file actions
45 lines (31 loc) · 1.13 KB
/
Copy pathbundlewatch.config.js
File metadata and controls
45 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// https://bundlewatch.io/#/getting-started/using-a-config-file
const { execSync } = require('child_process');
let outputPackages;
const getMaxSizeForPackage = packageLocation => {
const { maxBundleSize } = require(`${packageLocation}/package.json`);
return maxBundleSize;
};
const getPackageLocations = () => {
try {
let command = 'npx lerna ls --json';
outputPackages = execSync(command);
} catch (error) {
console.info('No changed packages found.');
process.exit(0);
}
const packagesArray = JSON.parse(outputPackages.toString());
const packageLocations = packagesArray.map(package => package.location);
const filteredPackages = packageLocations.filter(packageLocation => getMaxSizeForPackage(packageLocation) !== undefined);
return filteredPackages;
};
const packagesLocations = getPackageLocations();
const files = packagesLocations.map(packageLocation => ({
path: `${packageLocation}/dist/*+(.min|.min.umd|.es).js`,
maxSize: getMaxSizeForPackage(packageLocation)
}));
module.exports = {
files,
ci: {
"trackBranches": ["master", "main"]
}
};