source: trip-planner-front/node_modules/@angular/cdk/schematics/utils/project-style-file.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.7 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.getProjectStyleFile = void 0;
11const core_1 = require("@angular-devkit/core");
12const project_targets_1 = require("./project-targets");
13/** Regular expression that matches all possible Angular CLI default style files. */
14const defaultStyleFileRegex = /styles\.(c|le|sc)ss/;
15/** Regular expression that matches all files that have a proper stylesheet extension. */
16const validStyleFileRegex = /\.(c|le|sc)ss/;
17/**
18 * Gets a style file with the given extension in a project and returns its path. If no
19 * extension is specified, any style file with a valid extension will be returned.
20 */
21function getProjectStyleFile(project, extension) {
22 const buildOptions = project_targets_1.getProjectTargetOptions(project, 'build');
23 if (buildOptions.styles && core_1.isJsonArray(buildOptions.styles) && buildOptions.styles.length) {
24 const styles = buildOptions.styles.map(s => typeof s === 'string' ? s : s.input);
25 // Look for the default style file that is generated for new projects by the Angular CLI. This
26 // default style file is usually called `styles.ext` unless it has been changed explicitly.
27 const defaultMainStylePath = styles
28 .find(file => extension ? file === `styles.${extension}` : defaultStyleFileRegex.test(file));
29 if (defaultMainStylePath) {
30 return core_1.normalize(defaultMainStylePath);
31 }
32 // If no default style file could be found, use the first style file that matches the given
33 // extension. If no extension specified explicitly, we look for any file with a valid style
34 // file extension.
35 const fallbackStylePath = styles
36 .find(file => extension ? file.endsWith(`.${extension}`) : validStyleFileRegex.test(file));
37 if (fallbackStylePath) {
38 return core_1.normalize(fallbackStylePath);
39 }
40 }
41 return null;
42}
43exports.getProjectStyleFile = getProjectStyleFile;
44//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdC1zdHlsZS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