( tree: Tree, project: WizardProject, )
| 160 | } |
| 161 | |
| 162 | async function addPackageJsonScript( |
| 163 | tree: Tree, |
| 164 | project: WizardProject, |
| 165 | ): Promise<void> { |
| 166 | const filePath = toUnixPath(path.join(project.relativeDir, 'package.json')); |
| 167 | const raw = await tree.read(filePath); |
| 168 | if (raw == null) { |
| 169 | return; |
| 170 | } |
| 171 | const packageJson = JSON.parse(raw); |
| 172 | if (hasScript(packageJson, TASK_NAME)) { |
| 173 | return; |
| 174 | } |
| 175 | const updated = { |
| 176 | ...packageJson, |
| 177 | scripts: { |
| 178 | ...packageJson.scripts, |
| 179 | [TASK_NAME]: 'code-pushup', |
| 180 | }, |
| 181 | }; |
| 182 | await tree.write(filePath, `${JSON.stringify(updated, null, 2)}\n`); |
| 183 | } |
| 184 | |
| 185 | function toProject(cwd: string, pkg: WorkspacePackage): WizardProject { |
| 186 | return { |
no test coverage detected