Skip to content

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

Closed
beeman wants to merge 1 commit into
angular:masterfrom
beeman:angular-cli-warning
Closed

beeman wants to merge 1 commit into
angular:masterfrom
beeman:angular-cli-warning

Conversation

@beeman

@beeman beeman commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread packages/@angular/cli/bin/ng Outdated
}

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

!! is preferred.

@hansl

hansl commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

cc @StephenFluin @robwormald

LGTM outside of the nit above.

@beeman
beeman force-pushed the angular-cli-warning branch from cb739db to 58c3559 Compare February 6, 2017 20:16
@beeman

beeman commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

Nit addressed

@beeman
beeman force-pushed the angular-cli-warning branch from 58c3559 to b831158 Compare February 6, 2017 20:43
@beeman

beeman commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

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
beeman force-pushed the angular-cli-warning branch from b831158 to f497345 Compare February 6, 2017 21:03
@beeman
beeman force-pushed the angular-cli-warning branch from f497345 to 1f87128 Compare February 6, 2017 21:04
@beeman

beeman commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

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

`));
}

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

Copy link
Copy Markdown
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).

@hansl hansl left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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
mostafaibr pushed a commit to mostafaibr/angular-cli that referenced this pull request May 29, 2026
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.

3 participants