Skip to content

Commit ccab53a

Browse files
committed
.
1 parent 5be71ef commit ccab53a

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

scripts/ci/forbidden-identifiers.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const blocked_statements = [
2929
];
3030

3131
const sourceFolders = ['./src', './e2e'];
32-
const scopePackages = glob('src/lib/*');
32+
const libRoot = 'src/lib';
3333
const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
3434
const importRegex = /from\s+'(.*)';/g;
3535

@@ -58,7 +58,9 @@ findTestFiles()
5858
lineCount++;
5959

6060
let matches = line.match(blockedRegex);
61-
let scopeImport = isRelativeScopeImport(fileName, line);
61+
let scopeImport = path.relative(libRoot, fileName).startsWith('..')
62+
? isRelativeScopeImport(fileName, line)
63+
: false;
6264

6365
if (matches || scopeImport) {
6466

@@ -155,6 +157,10 @@ function findChangedFiles() {
155157
* @param line Line to be checked.
156158
*/
157159
function isRelativeScopeImport(fileName, line) {
160+
if (fileName.startsWith(libRoot)) {
161+
return false;
162+
}
163+
158164
let importMatch = importRegex.exec(line);
159165

160166
// We have to reset the last index of the import regex, otherwise we
@@ -184,8 +190,7 @@ function isRelativeScopeImport(fileName, line) {
184190
if (fileScope.path !== importScope.path) {
185191

186192
// Creates a valid import statement, which uses the correct scope package.
187-
let importFilePath = path.relative(importScope.path, importPath);
188-
let validImportPath = `@angular/material/${importScope.name}/${importFilePath}`;
193+
let validImportPath = `@angular/material`;
189194

190195
return {
191196
fileScope: fileScope.name,
@@ -200,9 +205,7 @@ function isRelativeScopeImport(fileName, line) {
200205
filePath = path.normalize(filePath);
201206

202207
// Iterate through all scope paths and try to find them inside of the file path.
203-
var scopePath = scopePackages
204-
.filter(scope => filePath.indexOf(path.normalize(scope)) !== -1)
205-
.pop();
208+
var scopePath = filePath.indexOf(path.normalize(libRoot)) == -1 ? libRoot : filePath;
206209

207210
// Return an object containing the name of the scope and the associated path.
208211
return {

tools/gulp/tasks/unit-test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ gulp.task(':test:deps', sequenceTask(
2626
[
2727
':build:test:vendor',
2828
':build:components:assets',
29-
':build:components:scss',
3029
':build:components:spec',
30+
':build:components:inline',
3131
':watch:components:spec',
3232
]
3333
));
@@ -39,12 +39,8 @@ gulp.task('test', [':test:deps'], (done: () => void) => {
3939
});
4040

4141
gulp.task('test:single-run', [':test:deps'], (done: () => void) => {
42-
runSequence(
43-
':inline-resources',
44-
() => {
45-
new karma.Server({
46-
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),
47-
singleRun: true
48-
}, done).start();
49-
});
42+
new karma.Server({
43+
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),
44+
singleRun: true
45+
}, done).start();
5046
});

0 commit comments

Comments
 (0)