ngx-progress-indicator
Version:
A progress indicator library for [Angular](https://angular.io/) apps.
30 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngAdd = void 0;
const schematics_1 = require("@angular-devkit/schematics");
const tasks_1 = require("@angular-devkit/schematics/tasks");
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
const change_1 = require("@schematics/angular/utility/change");
const ts = require("typescript");
function ngAdd() {
return (tree, context) => {
context.logger.info('Adding library module...');
const modulePath = '/src/app/app.module.ts';
if (!tree.exists(modulePath)) {
throw new schematics_1.SchematicsException(`${modulePath} does not exist...`);
}
const recorder = tree.beginUpdate(modulePath);
const content = tree.read(modulePath);
if (content === null) {
throw new schematics_1.SchematicsException(`${modulePath} does not exist...`);
}
const sourceFile = ts.createSourceFile(modulePath, content.toString(), ts.ScriptTarget.Latest, true);
(0, change_1.applyToUpdateRecorder)(recorder, (0, ast_utils_1.addImportToModule)(sourceFile, modulePath, `NgxProgressIndicatorModule.forRoot({ color: '#0083ff', size: 2 })`, 'ngx-progress-indicator'));
tree.commitUpdate(recorder);
context.logger.info('Installing dependencies...');
context.addTask(new tasks_1.NodePackageInstallTask());
return tree;
};
}
exports.ngAdd = ngAdd;
//# sourceMappingURL=index.js.map