MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / updatePackageJsonScript

Function updatePackageJsonScript

packages/baseai/src/init/index.ts:189–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187}
188
189async function updatePackageJsonScript(): Promise<void> {
190 try {
191 const packageJsonPath = path.join(process.cwd(), 'package.json');
192 const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
193 const packageJson = JSON.parse(packageJsonContent);
194
195 if (!packageJson.scripts) {
196 packageJson.scripts = {};
197 }
198
199 if (
200 !packageJson.scripts.baseai ||
201 packageJson.scripts.baseai !== 'baseai'
202 ) {
203 packageJson.scripts.baseai = 'baseai';
204 await fs.writeFile(
205 packageJsonPath,
206 JSON.stringify(packageJson, null, 2)
207 );
208 p.log.success('Added "baseai" script in package.json');
209 } else {
210 // p.log.info(
211 // '"baseai" script already exists and is correct in package.json'
212 // );
213 }
214 } catch (error) {
215 exitSetupFailed({
216 errorMessage: `Failed to update package.json: ${error instanceof Error ? error.message : String(error)}`,
217 warningMessage:
218 'Ensure you have permission to modify the package.json file.'
219 });
220 }
221}
222
223function displayOutro({ calledAsCommand }: { calledAsCommand: boolean }): void {
224 if (calledAsCommand) {

Callers 1

initFunction · 0.85

Calls 1

exitSetupFailedFunction · 0.85

Tested by

no test coverage detected