Skip to content

Commit 940dd88

Browse files
committed
add log and combineGlobs helper in syntax_test.js
1 parent c9aa098 commit 940dd88

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

test/syntax_test.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ var glob = require('glob');
66

77
var constants = require('../tasks/util/constants');
88

9+
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
10+
var libGlob = path.join(constants.pathToLib, '**/*.js');
11+
var testGlob = path.join(constants.pathToJasmineTests, '**/*.js');
12+
var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js');
913

1014
// main
1115
assertJasmineSuites();
@@ -14,11 +18,9 @@ assertHeaders();
1418
// check for for focus and exclude jasmine blocks
1519
function assertJasmineSuites() {
1620
var BLACK_LIST = ['fdescribe', 'fit', 'xdescribe', 'xit'];
17-
var testGlob = path.join(constants.pathToJasmineTests, '**/*.js');
18-
var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js');
1921
var logs = [];
2022

21-
glob('{' + testGlob + ',' + bundleTestGlob + '}', function(err, files) {
23+
glob(combineGlobs([testGlob, bundleTestGlob]), function(err, files) {
2224
files.forEach(function(file) {
2325
var code = fs.readFileSync(file, 'utf-8');
2426

@@ -35,21 +37,17 @@ function assertJasmineSuites() {
3537

3638
});
3739

38-
if(logs.length) {
39-
throw new Error('\n' + logs.join('\n') + '\n');
40-
}
40+
log(logs);
4141
});
4242
}
4343

4444
// check for header in src and lib files
4545
function assertHeaders() {
4646
var licenseSrc = constants.licenseSrc;
4747
var licenseStr = licenseSrc.substring(2, licenseSrc.length - 2);
48-
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
49-
var libGlob = path.join(constants.pathToLib, '**/*.js');
5048
var logs = [];
5149

52-
glob('{' + srcGlob + ',' + libGlob + '}', function(err, files) {
50+
glob(combineGlobs([srcGlob, libGlob]), function(err, files) {
5351
files.forEach(function(file) {
5452
var code = fs.readFileSync(file, 'utf-8');
5553

@@ -69,8 +67,16 @@ function assertHeaders() {
6967
}
7068
});
7169

72-
if(logs.length) {
73-
throw new Error('\n' + logs.join('\n') + '\n');
74-
}
70+
log(logs);
7571
});
7672
}
73+
74+
function combineGlobs(arr) {
75+
return '{' + arr.join(',') + '}';
76+
}
77+
78+
function log(logs) {
79+
if(logs.length) {
80+
throw new Error('\n' + logs.join('\n') + '\n');
81+
}
82+
}

0 commit comments

Comments
 (0)