-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (39 loc) · 1.33 KB
/
index.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
43
/**
* espower-traceur - power-assert instrumentor for traceur
*
* Copyright (c) 2014 Yosuke Furukawa
* Licensed under the MIT license.
*/
var traceur = require('traceur');
var minimatch = require('minimatch');
var extend = require('xtend');
var convert = require('convert-source-map');
var espowerSource = require('espower-source');
function espowerTraceur (options) {
'use strict';
var separator = (options.pattern.lastIndexOf('/', 0) === 0) ? '' : '/',
pattern = options.cwd + separator + options.pattern;
var originCompile = traceur.compile;
// Transcode some source.
traceur.compile = function(contents, opts, srcPath, destPath) {
if (! minimatch(srcPath, pattern)) {
return originCompile(contents, opts, srcPath, destPath);
}
var compiled = originCompile(contents, opts, srcPath, destPath);
var espowerOptions = extend({ sourceRoot: options.cwd }, options.espowerOptions);
var espowered = espowerSource(
compiled,
srcPath,
espowerOptions
);
return espowered;
};
traceur.require.makeDefault(function (filename) {
// Don't compile our dependencies.
if (filename.indexOf('node_modules') !== -1) return false;
// Don't compile files not included our test dirs.
if (!minimatch(filename, pattern)) return false;
return true;
});
}
module.exports = espowerTraceur;