var browserify = require('../'); var vm = require('vm'); var test = require('tap').test; var fs = require('fs'); var testFiles = [ __dirname + '/multi_entry/a.js', __dirname + '/multi_entry/b.js', __dirname + '/multi_entry/c.js' ]; test('multi entry', function (t) { t.plan(6); var b = browserify([ testFiles[0], testFiles[1] ]); b.add(testFiles[2]); b.on('dep', function(row) { if (row.entry) { t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); } }); b.bundle(function (err, src) { var c = { times : 0, t : t }; vm.runInNewContext(src, c); }); }); test('multi entry relative', function (t) { t.plan(6); var rTestFiles = testFiles.map(function(x) { return x.replace(__dirname + '/', ''); }); var b = browserify({ entries: [rTestFiles[0], rTestFiles[1]], basedir: __dirname }); b.add(rTestFiles[2]); b.on('dep', function(row) { if (row.entry) { t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); } }); b.bundle(function (err, src) { var c = { times : 0, t : t }; vm.runInNewContext(src, c); }); }); test('multi entry relative cwd', function (t) { t.plan(6); var rTestFiles = testFiles.map(function(x) { return x.replace(__dirname + '/', './'); }); var b = browserify({ entries: [rTestFiles[0], rTestFiles[1]], basedir: __dirname }); b.add(rTestFiles[2]); b.on('dep', function(row) { if (row.entry) { t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); } }); b.bundle(function (err, src) { var c = { times : 0, t : t }; vm.runInNewContext(src, c); }); }); test('entries as streams', function (t) { t.plan(6); // commondir blows up with streams and without basedir var opts = { basedir: __dirname + '/multi_entry' }; var b = browserify([ fs.createReadStream(testFiles[0]), fs.createReadStream(testFiles[1]) ], opts); b.add(fs.createReadStream(testFiles[2])); b.on('dep', function(row) { if (row.entry) { t.similar( row.file, RegExp(__dirname + '/multi_entry/_stream_[\\d].js'), 'should be full entry path' ); } }); b.bundle(function (err, src) { var c = { times : 0, t : t }; vm.runInNewContext(src, c); }); });
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/browserify/test/multi_entry.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |