forked from nestjsx/crud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package-scripts.js
44 lines (36 loc) · 1.27 KB
/
package-scripts.js
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
const utils = require('nps-utils');
const getSeries = (args) => utils.series.nps(...args);
const names = ['util', 'crud-request', 'crud', 'crud-typeorm'];
const getBuildCmd = (pkg) => {
const str = 'npx lerna run build';
const scoped = (name) => `--scope @nestjsx/${name}`;
return pkg ? `${str} ${scoped(pkg)}` : getSeries(names.map((name) => `build.${name}`));
};
const getCleanCmd = (pkg) => {
const cmd = `npx rimraf ./packages/${pkg}/lib && npx rimraf ./packages/${pkg}/tsconfig.tsbuildinfo`;
return pkg ? cmd : getSeries(names.map((name) => `clean.${name}`));
};
const getTestCmd = (pkg, coverage) =>
`npx jest --runInBand -c=jest.config.js packages/${pkg ? pkg + '/' : ''} ${
coverage ? '--coverage' : ''
} --verbose`;
const setBuild = () =>
names.reduce((a, c) => ({ ...a, [c]: getBuildCmd(c) }), {
default: getBuildCmd(),
});
const setClean = () =>
names.reduce((a, c) => ({ ...a, [c]: getCleanCmd(c) }), {
default: getCleanCmd(),
});
const setTest = () =>
names.reduce((a, c) => ({ ...a, [c]: getTestCmd(c) }), {
default: getTestCmd(false, true),
coveralls: getTestCmd(false, true) + ' --coverageReporters=text-lcov | coveralls',
});
module.exports = {
scripts: {
test: setTest(),
build: setBuild(),
clean: setClean(),
},
};