-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathglobal-setup.verdaccio.ts
43 lines (37 loc) · 1.22 KB
/
global-setup.verdaccio.ts
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
import { setup as globalSetup } from './global-setup';
import { executeProcess, objectToCliArgs } from './packages/utils/src';
import {
VerdaccioEnvResult,
nxStartVerdaccioAndSetupEnv,
nxStopVerdaccioAndTeardownEnv,
} from './tools/src/verdaccio/env';
let activeRegistry: VerdaccioEnvResult;
const projectName = process.env['NX_TASK_TARGET_PROJECT'];
export async function setup() {
await globalSetup();
try {
activeRegistry = await nxStartVerdaccioAndSetupEnv({
projectName: projectName,
verbose: true,
});
} catch (error) {
console.error('Error starting local verdaccio registry:\n' + error.message);
throw error;
}
const { userconfig, workspaceRoot } = activeRegistry;
await executeProcess({
command: 'npx',
args: objectToCliArgs({
_: ['nx', 'setup-deps', projectName],
registry: activeRegistry.registry.url, // publish
userconfig, // publish & install
prefix: workspaceRoot, // install
}),
observer: { onStdout: stdout => console.info(stdout) },
});
}
export async function teardown() {
// NOTICE - Time saving optimization
// We skip uninstalling packages as the folder is deleted anyway
await nxStopVerdaccioAndTeardownEnv(activeRegistry);
}