Skip to content

Commit

Permalink
Added schematics for ng add command.
Browse files Browse the repository at this point in the history
  • Loading branch information
rspl-yuvraj committed Feb 28, 2020
1 parent 4152801 commit 13e840a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion projects/ngx-spinner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ngx-spinner",
"version": "8.1.0",
"schematics": "./schematics/collection.json",
"repository": {
"type": "git",
"url": "https://github.com/Napster2210/ngx-spinner.git"
Expand Down Expand Up @@ -45,4 +46,4 @@
"@angular/common": "^8.0.0",
"@angular/core": "^8.0.0"
}
}
}
9 changes: 9 additions & 0 deletions projects/ngx-spinner/schematics/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"description": "Add ngx-spinner to the project.",
"factory": "./ng-add/index#ngAdd"
}
}
}
10 changes: 10 additions & 0 deletions projects/ngx-spinner/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';

// Just return the tree
export function ngAdd(_options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
_context.addTask(new NodePackageInstallTask());
return tree;
};
}

0 comments on commit 13e840a

Please sign in to comment.