Skip to content

Commit

Permalink
fix(core): keep decorate-cli script for existing workspace usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 authored and FrozenPandaz committed Jan 11, 2023
1 parent c8021f7 commit 14b517d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/lib/decorate-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'nx/src/adapter/decorate-cli';
22 changes: 22 additions & 0 deletions packages/nx/src/adapter/decorate-cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { readFileSync, writeFileSync } from 'fs';

export function decorateCli() {
console.warn(
`Decoration of the Angular CLI is deprecated and will be removed in a future version.`
);
console.warn(
`Please replace usage of "ng <command>" in any scripts, particularly for CI, with "nx <command>".`
);
const path = 'node_modules/@angular/cli/lib/cli/index.js';
const angularCLIInit = readFileSync(path, 'utf-8');
const start = angularCLIInit.indexOf(`(options) {`) + 11;

const newContent = `${angularCLIInit.slice(0, start)}
if (!process.env['NX_CLI_SET']) {
require('nx/bin/nx');
return new Promise(function(res, rej) {});
}
${angularCLIInit.substring(start)}
`;
writeFileSync(path, newContent);
}

0 comments on commit 14b517d

Please sign in to comment.