paths_transform.js
1.83 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var browserify = require('../');
var vm = require('vm');
var test = require('tap').test;
function ensureTransform(t, buf) {
var srcAsString = (buf||'').toString('utf-8'),
containsAX = srcAsString.indexOf('AX') > -1,
containsAZ = srcAsString.indexOf('AZ') > -1;
t.notOk(containsAX,"should not contain AX's");
t.ok(containsAZ,"should contain AZ's");
}
test('absolute paths with transform property', function (t) {
t.plan(6);
var b = browserify({
transform: ['tr'],
basedir: __dirname,
paths: [ __dirname + '/paths/x', __dirname + '/paths/y' ],
entries: __dirname + '/paths/main.js'
});
b.bundle(function (err, src) {
t.ifError(err);
ensureTransform(t,src);
vm.runInNewContext(src, { t: t });
});
});
test('relative paths with transform property', function (t) {
t.plan(6);
var b = browserify({
transform: ['tr'],
basedir: __dirname,
paths: [ './paths/x', './paths/y' ],
entries: __dirname + '/paths/main.js'
});
b.bundle(function (err, src) {
t.ifError(err);
ensureTransform(t,src);
vm.runInNewContext(src, { t: t });
});
});
test('absolute paths with transform method', function (t) {
t.plan(6);
var b = browserify({
basedir: __dirname,
paths: [ __dirname + '/paths/x', __dirname + '/paths/y' ],
entries: __dirname + '/paths/main.js'
});
b.transform('tr');
b.bundle(function (err, src) {
t.ifError(err);
ensureTransform(t,src);
vm.runInNewContext(src, { t: t });
});
});
test('relative paths with transform method', function (t) {
t.plan(6);
var b = browserify({
basedir: __dirname,
paths: ['./paths/x', './paths/y' ],
entries: __dirname + '/paths/main.js'
});
b.transform('tr');
b.bundle(function (err, src) {
t.ifError(err);
ensureTransform(t,src);
vm.runInNewContext(src, { t: t });
});
});