-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
update-swcrc-path.ts
37 lines (30 loc) · 1.12 KB
/
update-swcrc-path.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
import {
joinPathFragments,
readProjectConfiguration,
Tree,
updateProjectConfiguration,
} from '@nrwl/devkit';
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';
import { SwcExecutorOptions } from '../../utils/schema';
type OldSwcExecutorOptions = SwcExecutorOptions & { swcrcPath?: string };
export function updateSwcrcPath(tree: Tree) {
forEachExecutorOptions(
tree,
'@nrwl/js:swc',
(_, projectName, targetName, configurationName) => {
const projectConfig = readProjectConfiguration(tree, projectName);
const executorOptions: OldSwcExecutorOptions = configurationName
? projectConfig.targets[targetName].configurations[configurationName]
: projectConfig.targets[targetName].options;
if (!executorOptions.swcrcPath) return;
const newSwcrcPath = joinPathFragments(
projectConfig.root,
executorOptions.swcrcPath
);
delete executorOptions.swcrcPath;
executorOptions.swcrc = newSwcrcPath;
updateProjectConfiguration(tree, projectName, projectConfig);
}
);
}
export default updateSwcrcPath;