flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
44
VISUALIZACION/node_modules/static-module/test/assign.js
generated
vendored
Executable file
44
VISUALIZACION/node_modules/static-module/test/assign.js
generated
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('assign', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var expected = [ 12, 555 ];
|
||||
var sm = staticModule({
|
||||
beep: { x: 4, f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'\nconsole.log(4 * 3);'
|
||||
+ '\nconsole.log(555);\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('assign comma', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var expected = [ 12, 555 ];
|
||||
var sm = staticModule({
|
||||
beep: { x: 4, f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('comma.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'x = 5;\n'
|
||||
+ 'console.log(4 * 3);\n'
|
||||
+ 'console.log(555);\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'assign', file));
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/assign/comma.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/assign/comma.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
x = 5, b = require('beep');
|
||||
console.log(b.x * 3);
|
||||
console.log(b.f(5));
|
||||
3
VISUALIZACION/node_modules/static-module/test/assign/source.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/assign/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
b = require('beep');
|
||||
console.log(b.x * 3);
|
||||
console.log(b.f(5));
|
||||
198
VISUALIZACION/node_modules/static-module/test/brfs.js
generated
vendored
Executable file
198
VISUALIZACION/node_modules/static-module/test/brfs.js
generated
vendored
Executable file
|
|
@ -0,0 +1,198 @@
|
|||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var vm = require('vm');
|
||||
|
||||
test('readFileSync', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync empty', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('empty.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'), '');
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('attribute.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute with multiple vars', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('attribute_vars.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'var x = 5, y = 2;'
|
||||
+ '\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute with multiple require vars', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('multi_require.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'var x = 5;'
|
||||
+ '\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute with multiple require vars including an uninitalized var', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('multi_require_with_uninitialized.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'var x;'
|
||||
+ '\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute with multiple require vars x5', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('x5.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8').replace(/;/g,''),
|
||||
'var a = 1, b = 2, c = 3, d = 4, '
|
||||
+ 'src = "beep boop\\n",\n'
|
||||
+ ' e = 5\n'
|
||||
+ 'console.log(src)\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync with bracket notation', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('brackets.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('readFileSync attribute bracket notation', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('attribute_brackets.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'\nvar src = "beep boop\\n";'
|
||||
+ '\nconsole.log(src);\n'
|
||||
);
|
||||
vm.runInNewContext(body.toString('utf8'), {
|
||||
console: { log: log }
|
||||
});
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'brfs', file));
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var f = require('fs').readFileSync;
|
||||
var src = f(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute_brackets.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute_brackets.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var f = require('fs')["readFileSync"];
|
||||
var src = f(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute_vars.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/attribute_vars.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var x = 5, f = require('fs').readFileSync, y = 2;
|
||||
var src = f(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/brackets.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/brackets.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs');
|
||||
var src = fs["readFileSync"](__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
0
VISUALIZACION/node_modules/static-module/test/brfs/empty.js
generated
vendored
Executable file
0
VISUALIZACION/node_modules/static-module/test/brfs/empty.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/multi_require.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/multi_require.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs'), x = 5;
|
||||
var src = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/multi_require_with_uninitialized.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/multi_require_with_uninitialized.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs'), x;
|
||||
var src = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
3
VISUALIZACION/node_modules/static-module/test/brfs/source.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/brfs/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs');
|
||||
var src = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(src);
|
||||
1
VISUALIZACION/node_modules/static-module/test/brfs/x.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/brfs/x.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
beep boop
|
||||
5
VISUALIZACION/node_modules/static-module/test/brfs/x5.js
generated
vendored
Executable file
5
VISUALIZACION/node_modules/static-module/test/brfs/x5.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
var a = 1, b = 2, fs = require('fs'),
|
||||
c = 3, d = 4, src = fs.readFileSync(__dirname + '/x.txt', 'utf8'),
|
||||
e = 5
|
||||
;
|
||||
console.log(src);
|
||||
19
VISUALIZACION/node_modules/static-module/test/fn.js
generated
vendored
Executable file
19
VISUALIZACION/node_modules/static-module/test/fn.js
generated
vendored
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('function', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var sm = staticModule({ beep: function (n) { return n * 111 } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 555) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'fn', file));
|
||||
}
|
||||
2
VISUALIZACION/node_modules/static-module/test/fn/source.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/fn/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var b = require('beep');
|
||||
console.log(b(5));
|
||||
55
VISUALIZACION/node_modules/static-module/test/fs.js
generated
vendored
Executable file
55
VISUALIZACION/node_modules/static-module/test/fs.js
generated
vendored
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var through = require('through2');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('fs.readFile', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: { readFile: readFile }
|
||||
}, { vars: { __dirname: __dirname + '/fs' } });
|
||||
readStream('readfile.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8').replace(/;/g,'').trim(),
|
||||
'process.nextTick(function(){(function (err, src) {\n'
|
||||
+ ' console.log(src)\n'
|
||||
+ '})(null,"beep boop\\n")})'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 'beep boop\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('fs.readFileSync', function (t) {
|
||||
t.plan(2);
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: readFileSync }
|
||||
}, { vars: { __dirname: __dirname + '/fs' } });
|
||||
readStream('html.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'var html = "EXTERMINATE\\n";\n'
|
||||
+ 'console.log(html);\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 'EXTERMINATE\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'fs', file));
|
||||
}
|
||||
|
||||
function readFile (file, cb) {
|
||||
var stream = through(write, end);
|
||||
stream.push('process.nextTick(function(){(' + cb + ')(null,');
|
||||
return fs.createReadStream(file).pipe(quote()).pipe(stream);
|
||||
|
||||
function write (buf, enc, next) { this.push(buf); next() }
|
||||
function end (next) { this.push(')})'); this.push(null); next() }
|
||||
}
|
||||
|
||||
function readFileSync (file, opts) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
2
VISUALIZACION/node_modules/static-module/test/fs/html.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/fs/html.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var html = require('fs').readFileSync(__dirname + '/robot.html', 'utf8');
|
||||
console.log(html);
|
||||
4
VISUALIZACION/node_modules/static-module/test/fs/readfile.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/fs/readfile.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var fs = require('fs')
|
||||
fs.readFile(__dirname + '/x.txt', function (err, src) {
|
||||
console.log(src);
|
||||
});
|
||||
1
VISUALIZACION/node_modules/static-module/test/fs/robot.html
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/fs/robot.html
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
EXTERMINATE
|
||||
1
VISUALIZACION/node_modules/static-module/test/fs/x.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/fs/x.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
beep boop
|
||||
84
VISUALIZACION/node_modules/static-module/test/fs_twice.js
generated
vendored
Executable file
84
VISUALIZACION/node_modules/static-module/test/fs_twice.js
generated
vendored
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var through = require('through2');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('fs.readFileSync twice', function (t) {
|
||||
var expected = [ 'EXTERMINATE\n', 'beep boop\n' ];
|
||||
t.plan(expected.length + 1);
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: readFileSync }
|
||||
}, { vars: { __dirname: __dirname + '/fs_twice' } });
|
||||
readStream('html.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'),
|
||||
'var a = "EXTERMINATE\\n";\n'
|
||||
+ 'var b = "beep boop\\n";\n'
|
||||
+ 'console.log(a);\n'
|
||||
+ 'console.log(b);\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('fs.readFileSync twice in vars', function (t) {
|
||||
var expected = [ 'EXTERMINATE\n', 'beep boop\n' ];
|
||||
t.plan(expected.length + 1);
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: readFileSync }
|
||||
}, { vars: { __dirname: __dirname + '/fs_twice' } });
|
||||
readStream('vars.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8').trim(),
|
||||
'var a = "EXTERMINATE\\n",\n'
|
||||
+ ' b = "beep boop\\n";\n'
|
||||
+ 'console.log(a);\n'
|
||||
+ 'console.log(b);'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('fs.readFileSync 4x', function (t) {
|
||||
var expected = [
|
||||
'EXTERMINATE\n', 'beep boop\n', 'EXTERMINATE\n', 'beep boop\n'
|
||||
];
|
||||
t.plan(expected.length + 1);
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: readFileSync }
|
||||
}, { vars: { __dirname: __dirname + '/fs_twice' } });
|
||||
readStream('4x.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8').trim(),
|
||||
'var a = "EXTERMINATE\\n";\n'
|
||||
+ 'var b = "beep boop\\n";\n'
|
||||
+ 'var c = "EXTERMINATE\\n";\n'
|
||||
+ 'var d = "beep boop\\n";\n'
|
||||
+ 'console.log(a);\n'
|
||||
+ 'console.log(b);\n'
|
||||
+ 'console.log(c);\n'
|
||||
+ 'console.log(d);'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'fs_twice', file));
|
||||
}
|
||||
|
||||
function readFile (file, cb) {
|
||||
var stream = through(write, end);
|
||||
stream.push('process.nextTick(function(){(' + cb + ')(null,');
|
||||
return fs.createReadStream(file).pipe(quote()).pipe(stream);
|
||||
|
||||
function write (buf, enc, next) { this.push(buf); next() }
|
||||
function end (next) { this.push(')})'); this.push(null); next() }
|
||||
}
|
||||
|
||||
function readFileSync (file, opts) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
9
VISUALIZACION/node_modules/static-module/test/fs_twice/4x.js
generated
vendored
Executable file
9
VISUALIZACION/node_modules/static-module/test/fs_twice/4x.js
generated
vendored
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
var fs = require('fs');
|
||||
var a = fs.readFileSync(__dirname + '/robot.html', 'utf8');
|
||||
var b = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
var c = fs.readFileSync(__dirname + '/robot.html', 'utf8');
|
||||
var d = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(a);
|
||||
console.log(b);
|
||||
console.log(c);
|
||||
console.log(d);
|
||||
4
VISUALIZACION/node_modules/static-module/test/fs_twice/html.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/fs_twice/html.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var a = require('fs').readFileSync(__dirname + '/robot.html', 'utf8');
|
||||
var b = require('fs').readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(a);
|
||||
console.log(b);
|
||||
4
VISUALIZACION/node_modules/static-module/test/fs_twice/readfile.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/fs_twice/readfile.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var fs = require('fs')
|
||||
fs.readFile(__dirname + '/x.txt', function (err, src) {
|
||||
console.log(src);
|
||||
});
|
||||
1
VISUALIZACION/node_modules/static-module/test/fs_twice/robot.html
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/fs_twice/robot.html
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
EXTERMINATE
|
||||
5
VISUALIZACION/node_modules/static-module/test/fs_twice/vars.js
generated
vendored
Executable file
5
VISUALIZACION/node_modules/static-module/test/fs_twice/vars.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
var fs = require('fs');
|
||||
var a = fs.readFileSync(__dirname + '/robot.html', 'utf8'),
|
||||
b = fs.readFileSync(__dirname + '/x.txt', 'utf8');
|
||||
console.log(a);
|
||||
console.log(b);
|
||||
1
VISUALIZACION/node_modules/static-module/test/fs_twice/x.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/fs_twice/x.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
beep boop
|
||||
75
VISUALIZACION/node_modules/static-module/test/inline.js
generated
vendored
Executable file
75
VISUALIZACION/node_modules/static-module/test/inline.js
generated
vendored
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('inline object', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: { f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('obj.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 555) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('inline object call', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: { f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('obj_call.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 555) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('inline object expression', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: { f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('obj_expr.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 1110) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('inline function', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: function (n) { return n * 111 }
|
||||
});
|
||||
readStream('fn.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 555) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('inline function call', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: function (n) { return n * 111 }
|
||||
});
|
||||
readStream('fn_call.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 555) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('inline function expression', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: function (n) { return n * 111 }
|
||||
});
|
||||
readStream('fn_expr.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 1665) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'inline', file));
|
||||
}
|
||||
2
VISUALIZACION/node_modules/static-module/test/inline/fn.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/inline/fn.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var x = require('beep')(5);
|
||||
console.log(x);
|
||||
1
VISUALIZACION/node_modules/static-module/test/inline/fn_call.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/inline/fn_call.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('beep')(5));
|
||||
1
VISUALIZACION/node_modules/static-module/test/inline/fn_expr.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/inline/fn_expr.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('beep')(5) * 3);
|
||||
2
VISUALIZACION/node_modules/static-module/test/inline/obj.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/inline/obj.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var x = require('beep').f(5);
|
||||
console.log(x);
|
||||
1
VISUALIZACION/node_modules/static-module/test/inline/obj_call.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/inline/obj_call.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('beep').f(5));
|
||||
1
VISUALIZACION/node_modules/static-module/test/inline/obj_expr.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/inline/obj_expr.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('beep').f(5) * 2);
|
||||
23
VISUALIZACION/node_modules/static-module/test/limit-parsing.js
generated
vendored
Executable file
23
VISUALIZACION/node_modules/static-module/test/limit-parsing.js
generated
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
var concat = require('concat-stream');
|
||||
var from = require('from2-string');
|
||||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('limit parsing to files including a target module', function (t) {
|
||||
var passInput = 'THIS WILL NOT PARSE';
|
||||
var failInput = passInput + '; require("fs")';
|
||||
|
||||
t.plan(2);
|
||||
|
||||
from(passInput)
|
||||
.pipe(staticModule({ fs: require('fs') }))
|
||||
.pipe(concat(function (passOutput) {
|
||||
t.equal(passInput, String(passOutput), 'does not parse');
|
||||
}));
|
||||
|
||||
from(failInput)
|
||||
.pipe(staticModule({ fs: require('fs') }))
|
||||
.once('error', function () {
|
||||
t.pass('parses if module is included');
|
||||
});
|
||||
});
|
||||
45
VISUALIZACION/node_modules/static-module/test/log.js
generated
vendored
Executable file
45
VISUALIZACION/node_modules/static-module/test/log.js
generated
vendored
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('stream into a console.log', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: function () {
|
||||
var q = quote();
|
||||
q.end('eek');
|
||||
return q;
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'), 'console.log("eek");\n');
|
||||
}));
|
||||
});
|
||||
|
||||
test('trickle stream into a console.log', function (t) {
|
||||
t.plan(1);
|
||||
var sm = staticModule({
|
||||
beep: function () {
|
||||
var q = quote();
|
||||
var chunks = [ 'beep', ' boop', ' robots' ];
|
||||
var iv = setInterval(function () {
|
||||
if (chunks.length === 0) {
|
||||
clearInterval(iv);
|
||||
q.end();
|
||||
}
|
||||
else q.write(chunks.shift());
|
||||
}, 10);
|
||||
return q;
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'brfs') } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(body.toString('utf8'), 'console.log("beep boop robots");\n');
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'log', file));
|
||||
}
|
||||
1
VISUALIZACION/node_modules/static-module/test/log/source.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/log/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
console.log(require('beep')());
|
||||
74
VISUALIZACION/node_modules/static-module/test/many.js
generated
vendored
Executable file
74
VISUALIZACION/node_modules/static-module/test/many.js
generated
vendored
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('many instances', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
} }
|
||||
}, { vars: { __dirname: path.join(__dirname, 'many') } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nvar a = "A!\\n";\n'
|
||||
+ 'var b = "B!\\n";\n'
|
||||
+ 'var c = "C!\\n";\n'
|
||||
+ 'console.log(a + b + c);\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, 'A!\nB!\nC!\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('expansions inline', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
} }
|
||||
}, { vars: { __dirname: path.join(__dirname, 'many') } });
|
||||
readStream('inline.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nvar a = "A!\\n",\n'
|
||||
+ ' b = "B!\\n",\n'
|
||||
+ ' c = "C!\\n"\n'
|
||||
+ ';\n'
|
||||
+ 'console.log(a + b + c);\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, 'A!\nB!\nC!\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
test('all inline', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
} }
|
||||
}, { vars: { __dirname: path.join(__dirname, 'many') } });
|
||||
readStream('all_inline.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8').replace(/;/g,''),
|
||||
'var a = "A!\\n",\n'
|
||||
+ ' b = "B!\\n",\n'
|
||||
+ ' c = "C!\\n"\n'
|
||||
+ 'console.log(a + b + c)\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, 'A!\nB!\nC!\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'many', file));
|
||||
}
|
||||
1
VISUALIZACION/node_modules/static-module/test/many/a.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/many/a.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
A!
|
||||
6
VISUALIZACION/node_modules/static-module/test/many/all_inline.js
generated
vendored
Executable file
6
VISUALIZACION/node_modules/static-module/test/many/all_inline.js
generated
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
var fs = require('fs'),
|
||||
a = fs.readFileSync(__dirname + '/a.txt', 'utf8'),
|
||||
b = fs.readFileSync(__dirname + '/b.txt', 'utf8'),
|
||||
c = fs.readFileSync(__dirname + '/c.txt', 'utf8')
|
||||
;
|
||||
console.log(a + b + c);
|
||||
1
VISUALIZACION/node_modules/static-module/test/many/b.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/many/b.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
B!
|
||||
1
VISUALIZACION/node_modules/static-module/test/many/c.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/many/c.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
C!
|
||||
6
VISUALIZACION/node_modules/static-module/test/many/inline.js
generated
vendored
Executable file
6
VISUALIZACION/node_modules/static-module/test/many/inline.js
generated
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
var fs = require('fs');
|
||||
var a = fs.readFileSync(__dirname + '/a.txt', 'utf8'),
|
||||
b = fs.readFileSync(__dirname + '/b.txt', 'utf8'),
|
||||
c = fs.readFileSync(__dirname + '/c.txt', 'utf8')
|
||||
;
|
||||
console.log(a + b + c);
|
||||
5
VISUALIZACION/node_modules/static-module/test/many/source.js
generated
vendored
Executable file
5
VISUALIZACION/node_modules/static-module/test/many/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
var fs = require('fs');
|
||||
var a = fs.readFileSync(__dirname + '/a.txt', 'utf8');
|
||||
var b = fs.readFileSync(__dirname + '/b.txt', 'utf8');
|
||||
var c = fs.readFileSync(__dirname + '/c.txt', 'utf8');
|
||||
console.log(a + b + c);
|
||||
62
VISUALIZACION/node_modules/static-module/test/mixed.js
generated
vendored
Executable file
62
VISUALIZACION/node_modules/static-module/test/mixed.js
generated
vendored
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('mixed nested objects and streams', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var expected = [ 12, 'oh hello\n', 555 ];
|
||||
var sm = staticModule({
|
||||
beep: {
|
||||
x: { y: { z: 4 } },
|
||||
quote: {
|
||||
read: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
},
|
||||
f: { g: { h: function (n) { return n * 111 } } }
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'mixed') } });
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nconsole.log(4 * 3);'
|
||||
+ '\nconsole.log("oh hello\\n");'
|
||||
+ '\nconsole.log(555);\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('mixed objects and streams', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var expected = [ 12, 'oh hello\n', 555 ];
|
||||
var sm = staticModule({
|
||||
beep: {
|
||||
x: 4,
|
||||
quote: function (file) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
},
|
||||
f: function (n) { return n * 111 }
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'mixed') } });
|
||||
readStream('unmixed.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nconsole.log(4 * 3);'
|
||||
+ '\nconsole.log("oh hello\\n");'
|
||||
+ '\nconsole.log(555);\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'mixed', file));
|
||||
}
|
||||
4
VISUALIZACION/node_modules/static-module/test/mixed/source.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/mixed/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var b = require('beep');
|
||||
console.log(b.x.y.z * 3);
|
||||
console.log(b.quote.read(__dirname + '/xyz.txt'));
|
||||
console.log(b.f.g.h(5));
|
||||
4
VISUALIZACION/node_modules/static-module/test/mixed/unmixed.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/mixed/unmixed.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var b = require('beep');
|
||||
console.log(b.x * 3);
|
||||
console.log(b.quote(__dirname + '/xyz.txt'));
|
||||
console.log(b.f(5));
|
||||
1
VISUALIZACION/node_modules/static-module/test/mixed/xyz.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/mixed/xyz.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
oh hello
|
||||
29
VISUALIZACION/node_modules/static-module/test/nested.js
generated
vendored
Executable file
29
VISUALIZACION/node_modules/static-module/test/nested.js
generated
vendored
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('nested object', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var expected = [ 12, 555 ];
|
||||
var sm = staticModule({
|
||||
beep: {
|
||||
x: { y: { z: 4 } },
|
||||
f: { g: { h: function (n) { return n * 111 } } }
|
||||
}
|
||||
});
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nconsole.log(4 * 3);\nconsole.log(555);\n'
|
||||
);
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'nested', file));
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/nested/source.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/nested/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var b = require('beep');
|
||||
console.log(b.x.y.z * 3);
|
||||
console.log(b.f.g.h(5));
|
||||
22
VISUALIZACION/node_modules/static-module/test/obj.js
generated
vendored
Executable file
22
VISUALIZACION/node_modules/static-module/test/obj.js
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('object', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var expected = [ 12, 555 ];
|
||||
var sm = staticModule({
|
||||
beep: { x: 4, f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'obj', file));
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/obj/source.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/obj/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var b = require('beep');
|
||||
console.log(b.x * 3);
|
||||
console.log(b.f(5));
|
||||
21
VISUALIZACION/node_modules/static-module/test/prop.js
generated
vendored
Executable file
21
VISUALIZACION/node_modules/static-module/test/prop.js
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('property', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var sm = staticModule({
|
||||
fff: function (n) { return '[' + (n * 111) + ']' }
|
||||
});
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.deepEqual(msg, '[object Array]') }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'prop', file));
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/prop/source.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/prop/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var f = require('fff');
|
||||
var toString = Object.prototype.toString;
|
||||
console.log(toString.call(f(5)));
|
||||
34
VISUALIZACION/node_modules/static-module/test/readfile_resolve.js
generated
vendored
Executable file
34
VISUALIZACION/node_modules/static-module/test/readfile_resolve.js
generated
vendored
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
var staticModule = require('../');
|
||||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var through = require('through2');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var resolve = require('resolve');
|
||||
|
||||
test('readFileSync of require.resolve()', function (t) {
|
||||
t.plan(1);
|
||||
var dir = __dirname + '/readfile_resolve';
|
||||
function rres (p) { return resolve.sync(p, { basedir: dir }) }
|
||||
|
||||
var vars = {
|
||||
__dirname: dir,
|
||||
require: { resolve: rres }
|
||||
};
|
||||
var sm = staticModule({
|
||||
fs: { readFileSync: readFileSync }
|
||||
}, { vars: vars });
|
||||
readStream('main.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, 'amaze\n') }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'readfile_resolve', file));
|
||||
}
|
||||
|
||||
function readFileSync (file, opts) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
3
VISUALIZACION/node_modules/static-module/test/readfile_resolve/main.js
generated
vendored
Executable file
3
VISUALIZACION/node_modules/static-module/test/readfile_resolve/main.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs')
|
||||
var src = fs.readFileSync(require.resolve('aaa/wow.txt'), 'utf8');
|
||||
console.log(src);
|
||||
1
VISUALIZACION/node_modules/static-module/test/readfile_resolve/node_modules/aaa/wow.txt
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/readfile_resolve/node_modules/aaa/wow.txt
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
amaze
|
||||
22
VISUALIZACION/node_modules/static-module/test/shebang.js
generated
vendored
Executable file
22
VISUALIZACION/node_modules/static-module/test/shebang.js
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('shebang', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var expected = [ 12, 555 ];
|
||||
var sm = staticModule({
|
||||
beep: { x: 4, f: function (n) { return n * 111 } }
|
||||
});
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'shebang', file));
|
||||
}
|
||||
4
VISUALIZACION/node_modules/static-module/test/shebang/source.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/shebang/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
var b = require('beep');
|
||||
console.log(b.x * 3);
|
||||
console.log(b.f(5));
|
||||
126
VISUALIZACION/node_modules/static-module/test/sourcemap.js
generated
vendored
Executable file
126
VISUALIZACION/node_modules/static-module/test/sourcemap.js
generated
vendored
Executable file
|
|
@ -0,0 +1,126 @@
|
|||
var test = require('tape');
|
||||
var fs = require('fs');
|
||||
var concat = require('concat-stream');
|
||||
var PassThrough = require('stream').PassThrough;
|
||||
var convertSourceMap = require('convert-source-map');
|
||||
var SourceMapConsumer = require('source-map').SourceMapConsumer;
|
||||
var uglify = require('uglify-js');
|
||||
var staticModule = require('../');
|
||||
|
||||
test('source maps', function (t) {
|
||||
t.plan(6);
|
||||
|
||||
var transform = staticModule({
|
||||
sheetify: function (filename) {
|
||||
var stream = PassThrough();
|
||||
stream.write('`.css{\n');
|
||||
stream.write(' color: red;\n');
|
||||
stream.end('}`');
|
||||
return stream;
|
||||
}
|
||||
}, { sourceMap: true, inputFilename: 'main.js' });
|
||||
|
||||
fs.createReadStream(__dirname + '/sourcemap/main.js').pipe(transform).pipe(concat({ encoding: 'string' }, function (res) {
|
||||
var consumer = new SourceMapConsumer(convertSourceMap.fromSource(res).toObject());
|
||||
|
||||
var mapped = consumer.originalPositionFor({
|
||||
line: 8,
|
||||
column: 0
|
||||
});
|
||||
t.equal(mapped.line, 8);
|
||||
t.equal(mapped.column, 0);
|
||||
|
||||
mapped = consumer.originalPositionFor({
|
||||
line: 10,
|
||||
column: 2
|
||||
});
|
||||
t.equal(mapped.line, 8);
|
||||
t.equal(mapped.column, 19);
|
||||
|
||||
mapped = consumer.originalPositionFor({
|
||||
line: 12,
|
||||
column: 0
|
||||
});
|
||||
t.equal(mapped.line, 10);
|
||||
t.equal(mapped.column, 0);
|
||||
}));
|
||||
});
|
||||
|
||||
test('input source map', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var content = fs.readFileSync(__dirname + '/sourcemap/main.js', 'utf8');
|
||||
var minified = uglify.minify({ 'main.js': content }, {
|
||||
output: { beautify: true },
|
||||
sourceMap: {
|
||||
url: 'inline',
|
||||
includeSources: true
|
||||
}
|
||||
});
|
||||
|
||||
var transform = staticModule({
|
||||
sheetify: function (filename) {
|
||||
var stream = PassThrough();
|
||||
stream.end('`.css{\n color: orange;\n}`');
|
||||
return stream;
|
||||
}
|
||||
}, { sourceMap: true, inputFilename: 'main.js' });
|
||||
|
||||
transform.pipe(concat({ encoding: 'string' }, function (res) {
|
||||
var consumer = new SourceMapConsumer(convertSourceMap.fromSource(res).toObject());
|
||||
|
||||
var mapped = consumer.originalPositionFor({
|
||||
line: 7,
|
||||
column: 0
|
||||
});
|
||||
t.equal(mapped.line, 8);
|
||||
t.equal(mapped.column, 0);
|
||||
|
||||
mapped = consumer.originalPositionFor({
|
||||
line: 9,
|
||||
column: 4
|
||||
});
|
||||
t.equal(mapped.line, 10);
|
||||
t.equal(mapped.column, 0);
|
||||
}));
|
||||
|
||||
transform.end(minified.code);
|
||||
});
|
||||
|
||||
test('retain input source map when file has no static-module use', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var content = fs.readFileSync(__dirname + '/sourcemap/main.js', 'utf8');
|
||||
var minified = uglify.minify({ 'main.js': content }, {
|
||||
output: { beautify: true },
|
||||
sourceMap: {
|
||||
url: 'inline',
|
||||
includeSources: true
|
||||
}
|
||||
});
|
||||
|
||||
var transform = staticModule({
|
||||
not_sheetify: function () { return 'whatever'; }
|
||||
}, { sourceMap: true, inputFilename: 'main.js' });
|
||||
|
||||
transform.pipe(concat({ encoding: 'string' }, function (res) {
|
||||
var consumer = new SourceMapConsumer(convertSourceMap.fromSource(res).toObject());
|
||||
|
||||
var mapped = consumer.originalPositionFor({
|
||||
line: 7,
|
||||
column: 0
|
||||
});
|
||||
t.equal(mapped.line, 8);
|
||||
t.equal(mapped.column, 0);
|
||||
|
||||
mapped = consumer.originalPositionFor({
|
||||
line: 7,
|
||||
column: 21
|
||||
});
|
||||
t.equal(mapped.line, 10);
|
||||
t.equal(mapped.column, 0);
|
||||
}));
|
||||
|
||||
|
||||
transform.end(minified.code);
|
||||
});
|
||||
10
VISUALIZACION/node_modules/static-module/test/sourcemap/main.js
generated
vendored
Executable file
10
VISUALIZACION/node_modules/static-module/test/sourcemap/main.js
generated
vendored
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
var css = require('sheetify');
|
||||
|
||||
function doSomeStuff () {
|
||||
// doing some stuff before inlining a static module call
|
||||
return yadda(yadda)
|
||||
}
|
||||
|
||||
css('filename.css');
|
||||
|
||||
exports.blah = whatever.xyz
|
||||
33
VISUALIZACION/node_modules/static-module/test/unary.js
generated
vendored
Executable file
33
VISUALIZACION/node_modules/static-module/test/unary.js
generated
vendored
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('supported unary operator', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var expected = [ false ];
|
||||
var sm = staticModule({
|
||||
beep: { x: 42 }
|
||||
});
|
||||
readStream('supported.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('unsupported unary operator', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
var sm = staticModule({
|
||||
beep: { x: 42 }
|
||||
});
|
||||
readStream('unsupported.js').pipe(sm).on('error', function (error) {
|
||||
t.equal(error.message, 'unsupported unary operator: typeof')
|
||||
})
|
||||
})
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'unary', file));
|
||||
}
|
||||
2
VISUALIZACION/node_modules/static-module/test/unary/supported.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/unary/supported.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var beep = require('beep')
|
||||
console.log(!beep)
|
||||
2
VISUALIZACION/node_modules/static-module/test/unary/unsupported.js
generated
vendored
Executable file
2
VISUALIZACION/node_modules/static-module/test/unary/unsupported.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
var beep = require('beep')
|
||||
console.log(typeof beep)
|
||||
37
VISUALIZACION/node_modules/static-module/test/varmod.js
generated
vendored
Executable file
37
VISUALIZACION/node_modules/static-module/test/varmod.js
generated
vendored
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('variable modules', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var expected = [ 'beep boop!' ];
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file, enc) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, {
|
||||
vars: { __dirname: path.join(__dirname, 'vars') },
|
||||
varModules: { path: require('path') }
|
||||
});
|
||||
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(
|
||||
body.toString('utf8'),
|
||||
'\nvar path = require(\'path\');'
|
||||
+ '\nvar html = "beep boop";\nvar x = \'!\';'
|
||||
+ '\nconsole.log(html + x);\n'
|
||||
);
|
||||
Function(['console','require'],body)({ log: log },require);
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'varmod', file));
|
||||
}
|
||||
5
VISUALIZACION/node_modules/static-module/test/varmod/source.js
generated
vendored
Executable file
5
VISUALIZACION/node_modules/static-module/test/varmod/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var html = fs.readFileSync(path.join(__dirname, 'vars.html'), 'utf8');
|
||||
var x = '!';
|
||||
console.log(html + x);
|
||||
1
VISUALIZACION/node_modules/static-module/test/varmod/vars.html
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/varmod/vars.html
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
beep boop
|
||||
93
VISUALIZACION/node_modules/static-module/test/vars.js
generated
vendored
Executable file
93
VISUALIZACION/node_modules/static-module/test/vars.js
generated
vendored
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
var test = require('tape');
|
||||
var concat = require('concat-stream');
|
||||
var quote = require('quote-stream');
|
||||
var staticModule = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
test('multi-vars', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var expected = [ 'beep boop!' ];
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file, enc) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'vars') } });
|
||||
|
||||
readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(
|
||||
body.toString('utf8').replace(/;/g,''),
|
||||
'var html = "beep boop",\n x = \'!\'\nconsole.log(html + x)\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('2-var', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var expected = [ 'beep boop' ];
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file, enc) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'vars') } });
|
||||
|
||||
readStream('one.js').pipe(sm).pipe(concat(function (body) {
|
||||
t.equal(
|
||||
body.toString('utf8').replace(/;/g,''),
|
||||
'var html = "beep boop"\nconsole.log(html)\n'
|
||||
);
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('5-var', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var expected = [ 'beep boop123' ];
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file, enc) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, { vars: { __dirname: path.join(__dirname, 'vars') } });
|
||||
|
||||
readStream('five.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console'],body)({ log: log });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
test('multi consecutive require vars', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var expected = [ 'beep boop' ];
|
||||
var sm = staticModule({
|
||||
fs: {
|
||||
readFileSync: function (file, enc) {
|
||||
return fs.createReadStream(file).pipe(quote());
|
||||
}
|
||||
}
|
||||
}, {
|
||||
vars: { __dirname: path.join(__dirname, 'vars') },
|
||||
sourceMap: true // Make sure source maps work when replacing 0 length ranges.
|
||||
});
|
||||
|
||||
readStream('multi-require.js').pipe(sm).pipe(concat(function (body) {
|
||||
Function(['console','require'],body)({ log: log }, function() { return {} });
|
||||
function log (msg) { t.equal(msg, expected.shift()) }
|
||||
}));
|
||||
});
|
||||
|
||||
function readStream (file) {
|
||||
return fs.createReadStream(path.join(__dirname, 'vars', file));
|
||||
}
|
||||
6
VISUALIZACION/node_modules/static-module/test/vars/five.js
generated
vendored
Executable file
6
VISUALIZACION/node_modules/static-module/test/vars/five.js
generated
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
var a = 1, fs = require('fs'),
|
||||
b = 2,
|
||||
html = fs.readFileSync(__dirname + '/vars.html', 'utf8'),
|
||||
c = 3
|
||||
;
|
||||
console.log(html + a + b + c);
|
||||
14
VISUALIZACION/node_modules/static-module/test/vars/multi-require.js
generated
vendored
Executable file
14
VISUALIZACION/node_modules/static-module/test/vars/multi-require.js
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
var fs = require('fs'),
|
||||
tls = require('tls'),
|
||||
zlib = require('zlib'),
|
||||
Socket = require('net').Socket,
|
||||
EventEmitter = require('events').EventEmitter,
|
||||
inherits = require('util').inherits,
|
||||
inspect = require('util').inspect;
|
||||
|
||||
var foo = require('foo');
|
||||
var bar = require('bar');
|
||||
|
||||
var html = fs.readFileSync(__dirname + '/vars.html', 'utf8');
|
||||
|
||||
console.log(html);
|
||||
4
VISUALIZACION/node_modules/static-module/test/vars/one.js
generated
vendored
Executable file
4
VISUALIZACION/node_modules/static-module/test/vars/one.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
var fs = require('fs'),
|
||||
html = fs.readFileSync(__dirname + '/vars.html', 'utf8')
|
||||
;
|
||||
console.log(html);
|
||||
5
VISUALIZACION/node_modules/static-module/test/vars/source.js
generated
vendored
Executable file
5
VISUALIZACION/node_modules/static-module/test/vars/source.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
var fs = require('fs'),
|
||||
html = fs.readFileSync(__dirname + '/vars.html', 'utf8'),
|
||||
x = '!'
|
||||
;
|
||||
console.log(html + x);
|
||||
1
VISUALIZACION/node_modules/static-module/test/vars/vars.html
generated
vendored
Executable file
1
VISUALIZACION/node_modules/static-module/test/vars/vars.html
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
beep boop
|
||||
Loading…
Add table
Add a link
Reference in a new issue