-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (26 loc) · 703 Bytes
/
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
'use strict';
var estraverse = require('estraverse');
// monkey-patch for estraverse to accept File nodes
estraverse.Syntax.File = 'File';
estraverse.VisitorKeys.File = ['program'];
function traverse(options) {
var replace = !!(options && options.replace);
return function (files) {
if (!replace) {
return files.do(function (file) {
estraverse.traverse(file, options);
});
} else {
return files.map(function (file) {
return estraverse.replace(file, options);
});
}
};
}
Object.keys(estraverse.VisitorOption).forEach(function (key) {
Object.defineProperty(traverse, key, {
enumerable: true,
value: estraverse.VisitorOption[key]
});
});
module.exports = traverse;