MCPcopy Create free account
hub / github.com/code-pushup/cli / addNxTarget

Function addNxTarget

packages/create-cli/src/lib/setup/monorepo.ts:135–160  ·  view source on GitHub ↗
(
  tree: Tree,
  project: WizardProject,
)

Source from the content-addressed store, hash-verified

133}
134
135async function addNxTarget(
136 tree: Tree,
137 project: WizardProject,
138): Promise<boolean> {
139 const filePath = toUnixPath(path.join(project.relativeDir, 'project.json'));
140 const raw = await tree.read(filePath);
141 if (raw == null) {
142 return false;
143 }
144 const config = JSON.parse(raw);
145 if (config.targets?.[TASK_NAME] != null) {
146 return true;
147 }
148 const updated = {
149 ...config,
150 targets: {
151 ...config.targets,
152 [TASK_NAME]: {
153 executor: 'nx:run-commands',
154 options: { command: 'npx code-pushup' },
155 },
156 },
157 };
158 await tree.write(filePath, `${JSON.stringify(updated, null, 2)}\n`);
159 return true;
160}
161
162async function addPackageJsonScript(
163 tree: Tree,

Callers 1

addCodePushUpCommandFunction · 0.85

Calls 1

toUnixPathFunction · 0.90

Tested by

no test coverage detected