forked from nestjsx/crud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-scripts.js
More file actions
42 lines (35 loc) · 1.13 KB
/
Copy pathpackage-scripts.js
File metadata and controls
42 lines (35 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
const { readdirSync } = require('fs');
const { join } = require('path');
const utils = require('nps-utils');
const getSeries = (args) => utils.series.nps(...args);
const names = ['util', 'crud-request', 'crud'];
const packagesNames = readdirSync(join(__dirname, './packages'));
packagesNames.forEach((name) => {
if (!names.includes(name)) {
names.push(name);
}
});
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 getTestCmd = (pkg, coverage) =>
`npx jest -c=jest.config.js packages/${pkg ? pkg + '/' : ''} ${
coverage ? '--coverage' : ''
} --verbose`;
const setBuild = () =>
names.reduce((a, c) => ({ ...a, [c]: getBuildCmd(c) }), {
default: getBuildCmd(),
});
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(),
},
};