Skip to content

fix(@angular/cli): use realpath for project root #6403

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

Merged
merged 2 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,13 @@ const BuildCommand = Command.extend({
]),

run: function (commandOptions: BuildTaskOptions) {
const project = this.project;

// Check angular version.
Version.assertAngularVersionIs2_3_1OrHigher(project.root);
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);

const BuildTask = require('../tasks/build').default;

const buildTask = new BuildTask({
cliProject: project,
project: this.project,
ui: this.ui,
});

Expand Down
3 changes: 1 addition & 2 deletions packages/@angular/cli/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ const EjectCommand = Command.extend({
availableOptions: baseEjectCommandOptions,

run: function (commandOptions: EjectTaskOptions) {
const project = this.project;
const EjectTask = require('../tasks/eject').default;
const ejectTask = new EjectTask({
cliProject: project,
project: this.project,
ui: this.ui,
});

Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const InitCommand: any = Command.extend({
const InitTask = require('../tasks/init').default;

const initTask = new InitTask({
cliProject: this.project,
project: this.project,
tasks: this.tasks,
ui: this.ui,
Expand Down
7 changes: 3 additions & 4 deletions packages/@angular/cli/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ const SilentError = require('silent-error');

export default Task.extend({
run: function (runTaskOptions: BuildTaskOptions) {
const project = this.cliProject;
const config = CliConfig.fromProject().config;

const app = getAppFromConfig(runTaskOptions.app);

const outputPath = runTaskOptions.outputPath || app.outDir;
if (project.root === outputPath) {
if (this.project.root === outputPath) {
throw new SilentError('Output path MUST not be project root directory!');
}
if (config.project && config.project.ejected) {
throw new SilentError('An ejected project cannot use the build command anymore.');
}
if (runTaskOptions.deleteOutputPath) {
rimraf.sync(path.resolve(project.root, outputPath));
rimraf.sync(path.resolve(this.project.root, outputPath));
}

const webpackConfig = new NgCliWebpackConfig(runTaskOptions, app).buildConfig();
Expand All @@ -51,7 +50,7 @@ export default Task.extend({
const jsonStats = stats.toJson('verbose');

fs.writeFileSync(
path.resolve(project.root, outputPath, 'stats.json'),
path.resolve(this.project.root, outputPath, 'stats.json'),
JSON.stringify(jsonStats, null, 2)
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class JsonWebpackSerializer {

export default Task.extend({
run: function (runTaskOptions: EjectTaskOptions) {
const project = this.cliProject;
const project = this.project;
const cliConfig = CliConfig.fromProject();
const config = cliConfig.config;
const appConfig = getAppFromConfig(runTaskOptions.app);
Expand Down