Skip to content

Commit 0107543

Browse files
committed
chore(build): move build/transformCJSTests task to broccoli
1 parent 7d29636 commit 0107543

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

gulpfile.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,6 @@ gulp.task('build/transpile.js.cjs', transpile(gulp, gulpPlugins, {
370370
options: CONFIG.transpile.options.js.cjs,
371371
srcFolderInsertion: CONFIG.srcFolderInsertion.js
372372
}));
373-
gulp.task('build/transformCJSTests', function() {
374-
return gulp.src(CONFIG.dest.js.cjs + '/angular2/test/**/*_spec.js')
375-
.pipe(transformCJSTests())
376-
.pipe(gulp.dest(CONFIG.dest.js.cjs + '/angular2/test/'));
377-
});
378373

379374
gulp.task('build/transpile.dart', ['build.broccoli.tools'], function() {
380375
return broccoliBuild(makeBroccoliTree('dart'), 'dart');
@@ -807,7 +802,6 @@ gulp.task('build.js.cjs', function(done) {
807802
runSequence(
808803
'broccoli.js.cjs',
809804
['build/linknodemodules.js.cjs'],
810-
'build/transformCJSTests',
811805
done
812806
);
813807
});

tools/broccoli/make-broccoli-tree.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,25 @@ function makeCjsTree() {
159159
modules: 'commonjs'
160160
});
161161

162+
// Transform all tests to make them runnable in node
163+
cjsTree = replace(cjsTree, {
164+
files: ['**/test/**/*_spec.js'],
165+
patterns: [
166+
{
167+
// Override the default DOM adapter with Parse5 for all tests
168+
match: /"use strict";/,
169+
replacement:
170+
"'use strict'; var parse5Adapter = require('angular2/src/dom/parse5_adapter'); " +
171+
"parse5Adapter.Parse5DomAdapter.makeCurrent();"
172+
},
173+
{
174+
// Append main() to all tests since all of our tests are wrapped in exported main fn
175+
match: /$/g,
176+
replacement: "\r\n main();"
177+
}
178+
]
179+
});
180+
162181
// Now we add the LICENSE file into all the folders that will become npm packages
163182
outputPackages.forEach(function(destDir) {
164183
var license = new Funnel('.', {files: ['LICENSE'], destDir: destDir});

0 commit comments

Comments
 (0)