Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ng): add warning when angular-cli is detected locally #4466

Closed
wants to merge 1 commit into from

Conversation

beeman
Copy link
Contributor

@beeman beeman commented Feb 6, 2017

No description provided.

@@ -86,6 +86,34 @@ if (require('../package.json')['name'] == 'angular-cli'
`));
}

const packageJsonProject = require(path.join(process.cwd(), 'package.json'));
const hasOldDep = Boolean(packageJsonProject.dependencies['angular-cli']);
Copy link
Contributor

Choose a reason for hiding this comment

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

!! is preferred.

@hansl
Copy link
Contributor

hansl commented Feb 6, 2017

cc @StephenFluin @robwormald

LGTM outside of the nit above.

@beeman
Copy link
Contributor Author

beeman commented Feb 6, 2017

Nit addressed

@beeman
Copy link
Contributor Author

beeman commented Feb 6, 2017

WIP: Please don't merge yet.

I just found out that this causes an error when running it outside of a project:

$ cd
$ ng version
module.js:472
    throw err;
    ^

Error: Cannot find module '/Users/beeman/package.json'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Function.Module._load (/Users/beeman/workspace/angular-cli/angular-cli/lib/bootstrap-local.js:69:24)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/beeman/workspace/angular-cli/angular-cli/packages/@angular/cli/bin/ng:89:28)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

I will add a check for this.

@beeman
Copy link
Contributor Author

beeman commented Feb 6, 2017

Issues should be fixed, @hansl can you please re-review?

@@ -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).

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

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

Please make sure this works inside any dir in a project.

@hansl hansl closed this in ae89fde Feb 23, 2017
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this pull request Apr 12, 2017
@beeman beeman deleted the angular-cli-warning branch May 2, 2018 03:25
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants