-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
update-workspace.ts
43 lines (40 loc) · 1.14 KB
/
update-workspace.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 { JestProjectSchema } from '../schema';
import {
readProjectConfiguration,
Tree,
updateProjectConfiguration,
joinPathFragments,
normalizePath,
} from '@nrwl/devkit';
export function updateWorkspace(tree: Tree, options: JestProjectSchema) {
const projectConfig = readProjectConfiguration(tree, options.project);
projectConfig.targets.test = {
executor: '@nrwl/jest:jest',
outputs: [
joinPathFragments(
normalizePath('coverage'),
normalizePath(projectConfig.root)
),
],
options: {
jestConfig: joinPathFragments(
normalizePath(projectConfig.root),
`jest.config.${options.js ? 'js' : 'ts'}`
),
passWithNoTests: true,
},
};
const isUsingTSLint =
projectConfig.targets.lint?.executor ===
'@angular-devkit/build-angular:tslint';
if (isUsingTSLint) {
projectConfig.targets.lint.options.tsConfig = [
...(projectConfig.targets.lint.options.tsConfig || []),
joinPathFragments(
normalizePath(projectConfig.root),
'tsconfig.spec.json'
),
];
}
updateProjectConfiguration(tree, options.project, projectConfig);
}