-
Notifications
You must be signed in to change notification settings - Fork 78
/
postinstall.js
39 lines (34 loc) · 933 Bytes
/
postinstall.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
// This script will be executed on npm postinstall
const { exec } = require('child_process');
async function main() {
// Apply the husky configuration
await execCommand(`npm run prepare-husky`);
// Applying all the patches to the packages
await execCommand(`node ${require.resolve('patch-package')}`);
await execCommand(`npx nx run workspace:build`);
}
/**
* Executes a shell command and return it as a Promise.
* @param cmd {string}
* @return {Promise<string>}
*/
function execCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
return reject(error);
}
const output = stdout ? stdout : stderr;
console.log(output);
resolve(output);
});
});
}
main()
.then(() => {
console.log('✅ Successfully run postinstall script!');
})
.catch((error) => {
console.error(error);
process.exit(1);
});