Skip to content

Commit cd1aa18

Browse files
authored
bug(@angular/cli): Show module file update during dry run (#4836)
Fixes #4801
1 parent a2e819a commit cd1aa18

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

packages/@angular/cli/blueprints/component/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,19 @@ export default Blueprint.extend({
203203
},
204204

205205
afterInstall: function (options: any) {
206-
if (options.dryRun) {
207-
return;
208-
}
209-
210206
const returns: Array<any> = [];
211207
const className = stringUtils.classify(`${options.entity.name}Component`);
212208
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
213209
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
214210
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
215211

216212
if (!options.skipImport) {
213+
if (options.dryRun) {
214+
this._writeStatusToUI(chalk.yellow,
215+
'update',
216+
path.relative(this.project.root, this.pathToModule));
217+
return;
218+
}
217219
const preChange = fs.readFileSync(this.pathToModule, 'utf8');
218220

219221
returns.push(

packages/@angular/cli/blueprints/directive/index.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ export default Blueprint.extend({
132132
},
133133

134134
afterInstall: function(options: any) {
135-
if (options.dryRun) {
136-
return;
137-
}
138-
139135
const returns: Array<any> = [];
140136
const className = stringUtils.classify(`${options.entity.name}Directive`);
141137
const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
@@ -145,6 +141,12 @@ export default Blueprint.extend({
145141
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
146142

147143
if (!options.skipImport) {
144+
if (options.dryRun) {
145+
this._writeStatusToUI(chalk.yellow,
146+
'update',
147+
path.relative(this.project.root, this.pathToModule));
148+
return;
149+
}
148150
returns.push(
149151
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
150152
.then((change: any) => change.apply(NodeHost))
@@ -155,9 +157,9 @@ export default Blueprint.extend({
155157
}
156158
return result;
157159
}));
158-
this._writeStatusToUI(chalk.yellow,
159-
'update',
160-
path.relative(this.project.root, this.pathToModule));
160+
this._writeStatusToUI(chalk.yellow,
161+
'update',
162+
path.relative(this.project.root, this.pathToModule));
161163
}
162164

163165
return Promise.all(returns);

packages/@angular/cli/blueprints/pipe/index.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ export default Blueprint.extend({
112112
},
113113

114114
afterInstall: function(options: any) {
115-
if (options.dryRun) {
116-
return;
117-
}
118-
119115
const returns: Array<any> = [];
120116
const className = stringUtils.classify(`${options.entity.name}Pipe`);
121117
const fileName = stringUtils.dasherize(`${options.entity.name}.pipe`);
@@ -125,6 +121,12 @@ export default Blueprint.extend({
125121
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
126122

127123
if (!options.skipImport) {
124+
if (options.dryRun) {
125+
this._writeStatusToUI(chalk.yellow,
126+
'update',
127+
path.relative(this.project.root, this.pathToModule));
128+
return;
129+
}
128130
returns.push(
129131
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
130132
.then((change: any) => change.apply(NodeHost))
@@ -135,9 +137,9 @@ export default Blueprint.extend({
135137
}
136138
return result;
137139
}));
138-
this._writeStatusToUI(chalk.yellow,
139-
'update',
140-
path.relative(this.project.root, this.pathToModule));
140+
this._writeStatusToUI(chalk.yellow,
141+
'update',
142+
path.relative(this.project.root, this.pathToModule));
141143
}
142144

143145
return Promise.all(returns);

0 commit comments

Comments
 (0)