init
This commit is contained in:
17
node_modules/deps-sort/.travis.yml
generated
vendored
Normal file
17
node_modules/deps-sort/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "13"
|
||||
- "12"
|
||||
- "10"
|
||||
- "9"
|
||||
- "8"
|
||||
- "6"
|
||||
- "4"
|
||||
- "iojs"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
before_install:
|
||||
# Old npm certs are untrusted https://github.com/npm/npm/issues/20191
|
||||
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.8" ]; then export NPM_CONFIG_STRICT_SSL=false; fi'
|
||||
- 'nvm install-latest-npm'
|
21
node_modules/deps-sort/LICENSE
generated
vendored
Normal file
21
node_modules/deps-sort/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) James Halliday and browserify contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
10
node_modules/deps-sort/bin/cmd.js
generated
vendored
Normal file
10
node_modules/deps-sort/bin/cmd.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var argv = require('subarg')(process.argv.slice(2));
|
||||
var JSONStream = require('JSONStream');
|
||||
|
||||
var sort = require('../')(argv);
|
||||
var parse = JSONStream.parse([ true ]);
|
||||
var stringify = JSONStream.stringify();
|
||||
|
||||
process.stdin.pipe(parse).pipe(sort).pipe(stringify).pipe(process.stdout);
|
6
node_modules/deps-sort/example/sort.js
generated
vendored
Normal file
6
node_modules/deps-sort/example/sort.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var sort = require('../')();
|
||||
var JSONStream = require('JSONStream');
|
||||
var parse = JSONStream.parse([ true ]);
|
||||
var stringify = JSONStream.stringify();
|
||||
|
||||
process.stdin.pipe(parse).pipe(sort).pipe(stringify).pipe(process.stdout);
|
122
node_modules/deps-sort/index.js
generated
vendored
Normal file
122
node_modules/deps-sort/index.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
var through = require('through2');
|
||||
var shasum = require('shasum-object');
|
||||
|
||||
module.exports = function (opts) {
|
||||
if (!opts) opts = {};
|
||||
var rows = [];
|
||||
return through.obj(write, end);
|
||||
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
|
||||
function end () {
|
||||
var tr = this;
|
||||
rows.sort(cmp);
|
||||
sorter(rows, tr, opts);
|
||||
}
|
||||
};
|
||||
|
||||
function sorter (rows, tr, opts) {
|
||||
var expose = opts.expose || {};
|
||||
if (Array.isArray(expose)) {
|
||||
expose = expose.reduce(function (acc, key) {
|
||||
acc[key] = true;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
var hashes = {}, deduped = {};
|
||||
var sameDeps = depCmp();
|
||||
|
||||
if (opts.dedupe) {
|
||||
rows.forEach(function (row) {
|
||||
var h = shasum(row.source);
|
||||
sameDeps.add(row, h);
|
||||
if (hashes[h]) {
|
||||
hashes[h].push(row);
|
||||
} else {
|
||||
hashes[h] = [row];
|
||||
}
|
||||
});
|
||||
Object.keys(hashes).forEach(function (h) {
|
||||
var rows = hashes[h];
|
||||
while (rows.length > 1) {
|
||||
var row = rows.pop();
|
||||
row.dedupe = rows[0].id;
|
||||
row.sameDeps = sameDeps.cmp(rows[0].deps, row.deps);
|
||||
deduped[row.id] = rows[0].id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.index) {
|
||||
var index = {};
|
||||
var offset = 0;
|
||||
rows.forEach(function (row, ix) {
|
||||
if (has(expose, row.id)) {
|
||||
row.index = row.id;
|
||||
offset ++;
|
||||
if (expose[row.id] !== true) {
|
||||
index[expose[row.id]] = row.index;
|
||||
}
|
||||
}
|
||||
else {
|
||||
row.index = ix + 1 - offset;
|
||||
}
|
||||
index[row.id] = row.index;
|
||||
});
|
||||
rows.forEach(function (row) {
|
||||
row.indexDeps = {};
|
||||
Object.keys(row.deps).forEach(function (key) {
|
||||
var id = row.deps[key];
|
||||
row.indexDeps[key] = index[id];
|
||||
});
|
||||
if (row.dedupe) {
|
||||
row.dedupeIndex = index[row.dedupe];
|
||||
}
|
||||
tr.push(row);
|
||||
});
|
||||
}
|
||||
else {
|
||||
rows.forEach(function (row) { tr.push(row) });
|
||||
}
|
||||
tr.push(null);
|
||||
}
|
||||
|
||||
function cmp (a, b) {
|
||||
return a.id + a.hash < b.id + b.hash ? -1 : 1;
|
||||
}
|
||||
|
||||
function has (obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
function depCmp () {
|
||||
var deps = {}, hashes = {};
|
||||
return { add: add, cmp: cmp }
|
||||
|
||||
function add (row, hash) {
|
||||
deps[row.id] = row.deps;
|
||||
hashes[row.id] = hash;
|
||||
}
|
||||
function cmp (a, b, limit) {
|
||||
if (!a && !b) return true;
|
||||
if (!a || !b) return false;
|
||||
|
||||
var keys = Object.keys(a);
|
||||
if (keys.length !== Object.keys(b).length) return false;
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var k = keys[i], ka = a[k], kb = b[k];
|
||||
var ha = hashes[ka];
|
||||
var hb = hashes[kb];
|
||||
var da = deps[ka];
|
||||
var db = deps[kb];
|
||||
|
||||
if (ka === kb) continue;
|
||||
if (ha !== hb || (!limit && !cmp(da, db, 1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
42
node_modules/deps-sort/package.json
generated
vendored
Normal file
42
node_modules/deps-sort/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "deps-sort",
|
||||
"version": "2.0.1",
|
||||
"description": "sort module-deps output for deterministic browserify bundles",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"deps-sort": "bin/cmd.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"JSONStream": "^1.0.3",
|
||||
"shasum-object": "^1.0.0",
|
||||
"subarg": "^1.0.0",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^2.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/deps-sort.git"
|
||||
},
|
||||
"homepage": "https://github.com/substack/deps-sort",
|
||||
"keywords": [
|
||||
"dependency",
|
||||
"graph",
|
||||
"browser",
|
||||
"browserify",
|
||||
"module-deps",
|
||||
"browser-pack",
|
||||
"sorted",
|
||||
"determinism"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
107
node_modules/deps-sort/readme.markdown
generated
vendored
Normal file
107
node_modules/deps-sort/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
# deps-sort
|
||||
|
||||
sort [module-deps](https://npmjs.org/package/module-deps) output for deterministic
|
||||
browserify bundles
|
||||
|
||||
[](http://travis-ci.org/browserify/deps-sort)
|
||||
|
||||
# example
|
||||
|
||||
## command-line
|
||||
|
||||
```
|
||||
$ for((i=0;i<5;i++)); do module-deps main.js | deps-sort | browser-pack | md5sum; done
|
||||
e9e630de2c62953140357db0444c3c3a -
|
||||
e9e630de2c62953140357db0444c3c3a -
|
||||
e9e630de2c62953140357db0444c3c3a -
|
||||
e9e630de2c62953140357db0444c3c3a -
|
||||
e9e630de2c62953140357db0444c3c3a -
|
||||
```
|
||||
|
||||
or using `browserify --deps` on a [voxeljs](http://voxeljs.com/) project:
|
||||
|
||||
```
|
||||
$ for((i=0;i<5;i++)); do browserify --deps browser.js | deps-sort | browser-pack | md5sum; done
|
||||
fb418c74b53ba2e4cef7d01808b848e6 -
|
||||
fb418c74b53ba2e4cef7d01808b848e6 -
|
||||
fb418c74b53ba2e4cef7d01808b848e6 -
|
||||
fb418c74b53ba2e4cef7d01808b848e6 -
|
||||
fb418c74b53ba2e4cef7d01808b848e6 -
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
To use this module programmatically, write streaming object data and read
|
||||
streaming object data:
|
||||
|
||||
``` js
|
||||
var sort = require('../')();
|
||||
var JSONStream = require('JSONStream');
|
||||
var parse = JSONStream.parse([ true ]);
|
||||
var stringify = JSONStream.stringify();
|
||||
|
||||
process.stdin.pipe(parse).pipe(sort).pipe(stringify).pipe(process.stdout);
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var depsSort = require('deps-sort');
|
||||
```
|
||||
|
||||
## var stream = depsSort(opts)
|
||||
|
||||
Return a new through `stream` that should get written
|
||||
[module-deps](https://npmjs.org/package/module-deps) objects and will output
|
||||
sorted objects.
|
||||
|
||||
`opts` can be:
|
||||
|
||||
* `opts.index` - when true, for each module-deps row, insert `row.index` with
|
||||
the numeric index and `row.indexDeps` like `row.deps` but mapping require
|
||||
strings to row indices
|
||||
|
||||
* `opts.expose` - array of names or object mapping names to `true` not to mangle
|
||||
with integer indexes when `opts.index` is turned on. If `opts.expose` maps names
|
||||
to strings, those strings will be used to resolve the indexed references.
|
||||
|
||||
* `opts.dedupe` - set `row.dedupe` for files that match existing contents. Sets
|
||||
`row.dedupeIndex` when `opts.index` is enabled. When `row.dedupe` is set,
|
||||
`row.sameDeps` will be set to a boolean of whether the dependencies at the
|
||||
dedupe target match (true) or just the source content (false).
|
||||
|
||||
# input objects
|
||||
|
||||
Input objects are file objects in the [module-deps][] shape. They must at least
|
||||
have these properties:
|
||||
|
||||
* `row.id` - a unique identifier for the file
|
||||
* `row.source` - the file contents
|
||||
* `row.deps` - dependencies for this file, mapping strings as used in
|
||||
`require()` to row IDs.
|
||||
|
||||
# output objects
|
||||
|
||||
All the input properties, and:
|
||||
|
||||
* `row.index` - when `opts.index` is true, the sorted numeric index of the row
|
||||
* `row.indexDeps` - like `row.deps`, but mapping to `row.index` instead of
|
||||
`row.id`
|
||||
* `row.dedupe` - when `opts.dedupe` is true, contains the row ID of a file with
|
||||
identical contents
|
||||
* `row.dedupeIndex` - like `row.dedupe`, but contains the `row.index` instead
|
||||
of `row.id`
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install deps-sort
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
|
||||
[module-deps]: https://github.com/browserify/module-deps#output-objects
|
71
node_modules/deps-sort/test/dedupe-deps-of-deps.js
generated
vendored
Normal file
71
node_modules/deps-sort/test/dedupe-deps-of-deps.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('dedupe-deps-of-deps', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ dedupe: true });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{
|
||||
id: '/bar.js',
|
||||
deps: { baz: '/bar/baz.js' },
|
||||
source: 'TWO'
|
||||
},
|
||||
{
|
||||
id: '/bar/baz.js',
|
||||
deps: {},
|
||||
source: 'THREE'
|
||||
},
|
||||
{
|
||||
id: '/foo.js',
|
||||
deps: { baz: '/foo/baz.js' },
|
||||
source: 'TWO',
|
||||
dedupe: '/bar.js',
|
||||
sameDeps: true
|
||||
},
|
||||
{
|
||||
id: '/foo/baz.js',
|
||||
deps: {},
|
||||
source: 'THREE',
|
||||
dedupe: '/bar/baz.js',
|
||||
sameDeps: true
|
||||
},
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
}
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
});
|
||||
s.write({
|
||||
id: '/foo.js',
|
||||
deps: { baz : '/foo/baz.js' },
|
||||
source: 'TWO'
|
||||
});
|
||||
s.write({
|
||||
id: '/bar.js',
|
||||
deps: { baz : '/bar/baz.js' },
|
||||
source: 'TWO'
|
||||
});
|
||||
s.write({
|
||||
id: '/foo/baz.js',
|
||||
deps: {},
|
||||
source: 'THREE'
|
||||
});
|
||||
s.write({
|
||||
id: '/bar/baz.js',
|
||||
deps: {},
|
||||
source: 'THREE'
|
||||
});
|
||||
s.end();
|
||||
});
|
39
node_modules/deps-sort/test/dedupe.js
generated
vendored
Normal file
39
node_modules/deps-sort/test/dedupe.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('dedupe', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ dedupe: true });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{ id: '/bar.js', deps: {}, source: 'TWO' },
|
||||
{ id: '/foo.js', deps: {}, source: 'TWO', dedupe: '/bar.js', sameDeps: true },
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
}
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
});
|
||||
s.write({
|
||||
id: '/foo.js',
|
||||
deps: {},
|
||||
source: 'TWO'
|
||||
});
|
||||
s.write({
|
||||
id: '/bar.js',
|
||||
deps: {},
|
||||
source: 'TWO'
|
||||
});
|
||||
s.end();
|
||||
});
|
56
node_modules/deps-sort/test/dedupe_index.js
generated
vendored
Normal file
56
node_modules/deps-sort/test/dedupe_index.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('dedupe index', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ dedupe: true, index: true });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{
|
||||
id: '/bar.js',
|
||||
deps: {},
|
||||
source: 'TWO',
|
||||
index: 1,
|
||||
indexDeps: {}
|
||||
},
|
||||
{
|
||||
id: '/foo.js',
|
||||
deps: {},
|
||||
source: 'TWO',
|
||||
dedupe: '/bar.js',
|
||||
index: 2,
|
||||
indexDeps: {},
|
||||
dedupeIndex: 1,
|
||||
sameDeps: true
|
||||
},
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE',
|
||||
index: 3,
|
||||
indexDeps: { './foo': 2, './bar': 1 },
|
||||
}
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
});
|
||||
s.write({
|
||||
id: '/foo.js',
|
||||
deps: {},
|
||||
source: 'TWO'
|
||||
});
|
||||
s.write({
|
||||
id: '/bar.js',
|
||||
deps: {},
|
||||
source: 'TWO'
|
||||
});
|
||||
s.end();
|
||||
});
|
37
node_modules/deps-sort/test/dedupe_undef.js
generated
vendored
Normal file
37
node_modules/deps-sort/test/dedupe_undef.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('dedupe undef', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ dedupe: true });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{ id: '/bar.js', source: 'TWO' },
|
||||
{ id: '/foo.js', source: 'TWO', dedupe: '/bar.js', sameDeps: true },
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
}
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js', './bar': '/bar.js' },
|
||||
source: 'ONE'
|
||||
});
|
||||
s.write({
|
||||
id: '/foo.js',
|
||||
source: 'TWO'
|
||||
});
|
||||
s.write({
|
||||
id: '/bar.js',
|
||||
source: 'TWO'
|
||||
});
|
||||
s.end();
|
||||
});
|
38
node_modules/deps-sort/test/expose.js
generated
vendored
Normal file
38
node_modules/deps-sort/test/expose.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('expose true', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ index: true, expose: [ '/foo.js', '/bar.js' ] });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{
|
||||
id: '/bar.js',
|
||||
deps: {},
|
||||
index: '/bar.js',
|
||||
indexDeps: {}
|
||||
},
|
||||
{
|
||||
id: '/foo.js',
|
||||
deps: { './bar': '/bar.js' },
|
||||
index: '/foo.js',
|
||||
indexDeps: { './bar': '/bar.js' }
|
||||
},
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js' },
|
||||
index: 1,
|
||||
indexDeps: { './foo': '/foo.js' }
|
||||
},
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
|
||||
s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
|
||||
s.write({ id: '/bar.js', deps: {} });
|
||||
s.end();
|
||||
});
|
44
node_modules/deps-sort/test/expose_str.js
generated
vendored
Normal file
44
node_modules/deps-sort/test/expose_str.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('expose string', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({
|
||||
index: true,
|
||||
expose: {
|
||||
'f': '/foo.js',
|
||||
'b': '/bar.js'
|
||||
}
|
||||
});
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js' },
|
||||
index: 1,
|
||||
indexDeps: { './foo': 'f' }
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
deps: {},
|
||||
index: 'b',
|
||||
indexDeps: {}
|
||||
},
|
||||
{
|
||||
id: 'f',
|
||||
deps: { './bar': '/bar.js' },
|
||||
index: 'f',
|
||||
indexDeps: { './bar': 'b' }
|
||||
}
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
|
||||
s.write({ id: 'f', deps: { './bar': '/bar.js' } });
|
||||
s.write({ id: 'b', deps: {} });
|
||||
s.end();
|
||||
});
|
38
node_modules/deps-sort/test/indexed.js
generated
vendored
Normal file
38
node_modules/deps-sort/test/indexed.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('indexed', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort({ index: true });
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{
|
||||
id: '/bar.js',
|
||||
deps: {},
|
||||
index: 1,
|
||||
indexDeps: {}
|
||||
},
|
||||
{
|
||||
id: '/foo.js',
|
||||
deps: { './bar': '/bar.js' },
|
||||
index: 2,
|
||||
indexDeps: { './bar': 1 }
|
||||
},
|
||||
{
|
||||
id: '/main.js',
|
||||
deps: { './foo': '/foo.js' },
|
||||
index: 3,
|
||||
indexDeps: { './foo': 2 }
|
||||
},
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
|
||||
s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
|
||||
s.write({ id: '/bar.js', deps: {} });
|
||||
s.end();
|
||||
});
|
23
node_modules/deps-sort/test/sort.js
generated
vendored
Normal file
23
node_modules/deps-sort/test/sort.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var sort = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
|
||||
test('sort', function (t) {
|
||||
t.plan(1);
|
||||
var s = sort();
|
||||
var rows = [];
|
||||
function write (row, enc, next) { rows.push(row); next() }
|
||||
function end () {
|
||||
t.deepEqual(rows, [
|
||||
{ id: '/bar.js', deps: {} },
|
||||
{ id: '/foo.js', deps: { './bar': '/bar.js' } },
|
||||
{ id: '/main.js', deps: { './foo': '/foo.js' } }
|
||||
]);
|
||||
}
|
||||
s.pipe(through.obj(write, end));
|
||||
|
||||
s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
|
||||
s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
|
||||
s.write({ id: '/bar.js', deps: {} });
|
||||
s.end();
|
||||
});
|
Reference in New Issue
Block a user