noparse_row.js
1 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
var parser = require('../');
var test = require('tap').test;
var fs = require('fs');
var concat = require('concat-stream');
var path = require('path');
var files = {
main: path.join(__dirname, '/files/main.js'),
foo: path.join(__dirname, '/files/foo.js'),
bar: path.join(__dirname, '/files/bar.js')
};
var sources = Object.keys(files).reduce(function (acc, file) {
acc[file] = fs.readFileSync(files[file], 'utf8');
return acc;
}, {});
test('noParse row', function (t) {
t.plan(1);
var p = parser();
p.end({ file: files.main, noparse: true });
var rows = [];
p.on('data', function (row) { rows.push(row) });
p.on('end', function () {
t.deepEqual(rows.sort(cmp), [
{
id: files.main,
file: files.main,
source: sources.main,
entry: true,
noparse: true,
deps: {}
}
].sort(cmp));
});
});
function cmp (a, b) { return a.id < b.id ? -1 : 1 }