angular-toaster
Version:
An Angular Toaster Notification library based on AngularJS-Toaster
35 lines (34 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addThemeToAppStyles = addThemeToAppStyles;
const schematics_1 = require("@angular-devkit/schematics");
const workspace_1 = require("@schematics/angular/utility/workspace");
const project_1 = require("../../utils/project");
function addThemeToAppStyles(options) {
const themePath = "./node_modules/angular-toaster/toaster.css";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return (_host, _context) => {
return (0, schematics_1.chain)([
addThemeStyleToTarget(options.project, "build", themePath),
addThemeStyleToTarget(options.project, "test", themePath),
]);
};
}
function addThemeStyleToTarget(projectName, targetName, assetPath) {
return (0, workspace_1.updateWorkspace)((workspace) => {
// TODO: Types have separate declarations of a private property '_validateNam
const project = (0, project_1.getProjectFromWorkspace)(workspace, projectName);
// Do not update the builder options in case the target does not use the default CLI builder.
// if (!validateDefaultTargetBuilder(project, targetName, logger)) {
// return
// }
const targetOptions = (0, project_1.getProjectTargetOptions)(project, targetName);
const styles = targetOptions["styles"];
const existingStyles = styles.map((s) => typeof s === "string" ? s : s.input);
for (const [, stylePath] of existingStyles.entries()) {
if (stylePath === assetPath)
return;
}
styles.push(assetPath);
});
}