-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathbabel.js
36 lines (31 loc) · 944 Bytes
/
babel.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
'use strict';
var resolveFrom = require('resolve-from');
var createEspowerPlugin = require('babel-plugin-espower/create');
var requireFromString = require('require-from-string');
var hasGenerators = parseInt(process.version.slice(1), 10) > 0;
var testPath = process.argv[2];
var babel;
try {
var localBabel = resolveFrom('.', 'babel-core') || resolveFrom('.', 'babel');
babel = require(localBabel);
} catch (err) {
babel = require('babel-core');
}
var options = {
blacklist: hasGenerators ? ['regenerator'] : [],
optional: hasGenerators ? ['asyncToGenerator', 'runtime'] : ['runtime'],
plugins: [
createEspowerPlugin(babel, {
patterns: require('./enhance-assert').PATTERNS
})
]
};
var transpiled = babel.transformFileSync(testPath, options);
requireFromString(transpiled.code, testPath, {
appendPaths: module.paths
});
process.on('message', function (message) {
if (message['ava-kill-command']) {
process.exit(0);
}
});