-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
postinstall.mts
40 lines (33 loc) · 985 Bytes
/
postinstall.mts
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
import { $ as $_config } from 'execa';
const $ = $_config({
stdout: 'inherit',
stderr: 'inherit',
verbose: true,
});
/**
* In certain circumstances we might want to skip the below the steps when another
* tool is invoking the install command (such as when nx migrate runs).
* We therefore use an env var for this.
*/
if (process.env.SKIP_POSTINSTALL) {
console.log(
'\nSkipping postinstall script because $SKIP_POSTINSTALL is set...\n',
);
// eslint-disable-next-line no-process-exit
process.exit(0);
}
void (async function (): Promise<void> {
// make sure we're running from the workspace root
const {
default: { workspaceRoot },
} = await import('@nx/devkit');
process.chdir(workspaceRoot);
// Install git hooks
await $`yarn husky install`;
if (!process.env.SKIP_POSTINSTALL_BUILD) {
// Clean any caches that may be invalid now
await $`yarn clean`;
// Build all the packages ready for use
await $`yarn build`;
}
})();