-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtargets.ts
More file actions
29 lines (28 loc) · 1.03 KB
/
targets.ts
File metadata and controls
29 lines (28 loc) · 1.03 KB
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
import { readdir } from 'node:fs/promises';
import { CP_TARGET_NAME } from '../constants';
import type { NormalizedCreateNodesContext } from '../types';
import { createConfigurationTarget } from './configuration-target';
import { CODE_PUSHUP_CONFIG_REGEX } from './constants';
import { createExecutorTarget } from './executor-target';
export async function createTargets(
normalizedContext: NormalizedCreateNodesContext,
) {
const {
targetName = CP_TARGET_NAME,
bin,
projectPrefix,
} = normalizedContext.createOptions;
const rootFiles = await readdir(normalizedContext.projectRoot);
return rootFiles.some(filename => filename.match(CODE_PUSHUP_CONFIG_REGEX))
? {
[targetName]: createExecutorTarget({ bin, projectPrefix }),
}
: // if NO code-pushup.config.*.(ts|js|mjs) is present return configuration target
{
[`${targetName}--configuration`]: createConfigurationTarget({
targetName,
projectName: normalizedContext.projectJson.name,
bin,
}),
};
}