Skip to content

Commit bf3c519

Browse files
hanslfilipesilva
authored andcommitted
fix(@angular/cli): use an empty host for ng new
Creating the host means listing all files and directory. On large directories it can be quite expensive. On ng new however we do not need to list everything, only detect conflicts, so using an empty tree as the host of the schematics makes sense.
1 parent 38a7ab4 commit bf3c519

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/@angular/cli/tasks/init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default Task.extend({
7878
const runOptions = {
7979
taskOptions: commandOptions,
8080
workingDir: cwd,
81+
emptyHost: true,
8182
collectionName: commandOptions.collectionName,
8283
schematicName
8384
};

packages/@angular/cli/tasks/schematic-run.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
DryRunEvent,
33
DryRunSink,
4+
EmptyTree,
45
FileSystemSink,
56
FileSystemTree,
67
Schematic,
@@ -22,6 +23,7 @@ const Task = require('../ember-cli/lib/models/task');
2223
export interface SchematicRunOptions {
2324
taskOptions: SchematicOptions;
2425
workingDir: string;
26+
emptyHost: boolean;
2527
collectionName: string;
2628
schematicName: string;
2729
}
@@ -44,7 +46,7 @@ interface OutputLogging {
4446

4547
export default Task.extend({
4648
run: function (options: SchematicRunOptions): Promise<SchematicOutput> {
47-
const { taskOptions, workingDir, collectionName, schematicName } = options;
49+
const { taskOptions, workingDir, emptyHost, collectionName, schematicName } = options;
4850

4951
const ui = this.ui;
5052

@@ -63,7 +65,8 @@ export default Task.extend({
6365
const preppedOptions = prepOptions(schematic, taskOptions);
6466
const opts = { ...taskOptions, ...preppedOptions };
6567

66-
const host = Observable.of(new FileSystemTree(new FileSystemHost(workingDir)));
68+
const tree = emptyHost ? new EmptyTree() : new FileSystemTree(new FileSystemHost(workingDir));
69+
const host = Observable.of(tree);
6770

6871
const dryRunSink = new DryRunSink(workingDir, opts.force);
6972
const fsSink = new FileSystemSink(workingDir, opts.force);

0 commit comments

Comments
 (0)