forked from microsoft/fluentui-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beachball.hooks.js
58 lines (49 loc) · 1.43 KB
/
beachball.hooks.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// @ts-check
const childProcess = require('child_process');
/**
* @param {String} command
*
* @returns {Promise<string>}
*/
function sh(command) {
return new Promise((resolve, reject) => {
const [cmd, ...args] = command.split(' ');
/** @type {import('child_process').SpawnOptions} */
const options = {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
shell: true,
};
const child = childProcess.spawn(cmd, args, options);
let stdoutData = '';
if (child.stdout) {
child.stdout.on('data', data => {
stdoutData += data;
});
}
child.on('close', code => {
if (code === 0) {
resolve(stdoutData);
}
reject(new Error([`child process exited with code ${code}`, stdoutData].join('\n')));
});
});
}
let completedPrepublish = false;
/**
* @type {import('beachball').BeachballConfig['hooks']}
*/
module.exports = {
// Executed after all package versions were bumped -> run build
// If we run build before `beachball publish`, artifacts would have
// old (without bump) versions.
async prepublish() {
// `beachball` runs this hook for every package, we want to run it only once.
if (!completedPrepublish) {
await sh('yarn nx run-many --target=build --all --parallel --max-parallel=3');
await sh('yarn nx run-many --target=type-check --all --parallel --max-parallel=3');
completedPrepublish = true;
}
},
};