Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/@angular/cli/bin/ng
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ if (require('../package.json')['name'] == 'angular-cli'
`));
}

const packageJsonProjectPath = path.join(process.cwd(), 'package.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We allow people to run anywhere inside a project. You should use the __dirname instead (and potentially findup).

if (fs.existsSync(packageJsonProjectPath)) {
const packageJsonProject = require(packageJsonProjectPath);
const hasOldDep = !!packageJsonProject.dependencies['angular-cli'];
const hasOldDevDep = !!packageJsonProject.devDependencies['angular-cli'];
const hasDevDep = !!packageJsonProject.devDependencies['@angular/cli'];

if (hasOldDep || hasOldDevDep || !hasDevDep) {
const warnings = [
'The package "angular-cli" has been renamed to "@angular/cli". The old package will be deprecated soon.',
'Please take the following steps to avoid issues:'
];
if (hasOldDep) {
warnings.push('"npm uninstall --save angular-cli"');
}
if (hasOldDevDep) {
warnings.push('"npm uninstall --save-dev angular-cli"');
}
if (!hasDevDep) {
warnings.push('"npm install --save-dev @angular/cli@latest"');
}
process.stderr.write(yellow(warnings.join('\n\n'), '\n'));
}
}

resolve('@angular/cli', { basedir: process.cwd() },
function (error, projectLocalCli) {
Expand Down