-
Notifications
You must be signed in to change notification settings - Fork 2
/
shim.js
42 lines (35 loc) · 1.18 KB
/
shim.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*global process __dirname require*/
var walkSync = require('fs-tools').walkSync,
includes = require('lodash/includes'),
path = require('path');
var resolve = path.resolve,
basename = path.basename,
relative = path.relative;
/*
* Istanbul only instruments source files that are required by mocha while
* testing. This shim ensures all .js source files that exist in the es6 tree
* are required by mocha in the es5 tree.
*
* NOTE: We can't just require all .js files in the es5 tree, because they
* may become stale as the es6 tree changes.
*
* NOTE: We also can't require index.js, because that launches the server!
*/
console.log( '! mocha is now requiring all source .js files' );
console.log( '! see shim.js for details.\n' );
try {
var es6src = resolve( __dirname, 'src' );
var es5src = resolve( __dirname, 'lib' );
walkSync( es6src, '\.js$', function( path ) {
if ( !includes( [ ], basename( path ) ) ) {
var slug = relative( es6src, path );
var file = resolve( es5src, slug );
if ( process.env.NODE_ENV === 'development' ) {
console.log( '!', file );
}
require( file );
}
} );
} catch ( err ) {
console.error( err );
}