forked from enviPath/enviPy
Current Dev State
This commit is contained in:
18
static/js/ketcher2/node_modules/module-deps/LICENSE
generated
vendored
Normal file
18
static/js/ketcher2/node_modules/module-deps/LICENSE
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
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.
|
||||
28
static/js/ketcher2/node_modules/module-deps/bin/cmd.js
generated
vendored
Executable file
28
static/js/ketcher2/node_modules/module-deps/bin/cmd.js
generated
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
var mdeps = require('../');
|
||||
var subarg = require('subarg');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var argv = subarg(process.argv.slice(2), {
|
||||
alias: { h: 'help', t: 'transform', g: 'globalTransform' }
|
||||
});
|
||||
if (argv.help) return usage(0);
|
||||
|
||||
var JSONStream = require('JSONStream');
|
||||
|
||||
var files = argv._.map(function (file) {
|
||||
if (file === '-') return process.stdin;
|
||||
return path.resolve(file);
|
||||
});
|
||||
var md = mdeps(argv);
|
||||
md.pipe(JSONStream.stringify()).pipe(process.stdout);
|
||||
|
||||
files.forEach(function (file) { md.write(file) });
|
||||
md.end();
|
||||
|
||||
function usage (code) {
|
||||
var r = fs.createReadStream(__dirname + '/usage.txt');
|
||||
r.pipe(process.stdout);
|
||||
if (code) r.on('end', function () { process.exit(code) });
|
||||
}
|
||||
9
static/js/ketcher2/node_modules/module-deps/bin/usage.txt
generated
vendored
Normal file
9
static/js/ketcher2/node_modules/module-deps/bin/usage.txt
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
module-deps [FILES] OPTIONS
|
||||
|
||||
Generate json output for the entry point FILES.
|
||||
|
||||
OPTIONS are:
|
||||
|
||||
-t TRANSFORM Apply a TRANSFORM.
|
||||
-g TRANSFORM Apply a global TRANSFORM.
|
||||
|
||||
6
static/js/ketcher2/node_modules/module-deps/example/deps.js
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/module-deps/example/deps.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
var mdeps = require('../');
|
||||
var JSONStream = require('JSONStream');
|
||||
|
||||
var md = mdeps();
|
||||
md.pipe(JSONStream.stringify()).pipe(process.stdout);
|
||||
md.end({ file: __dirname + '/files/main.js' });
|
||||
3
static/js/ketcher2/node_modules/module-deps/example/files/bar.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/example/files/bar.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function (n) {
|
||||
return n * 100;
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/module-deps/example/files/foo.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/example/files/foo.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var bar = require('./bar');
|
||||
|
||||
module.exports = function (n) {
|
||||
return n * 111 + bar(n);
|
||||
};
|
||||
2
static/js/ketcher2/node_modules/module-deps/example/files/main.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/example/files/main.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var foo = require('./foo');
|
||||
console.log('main: ' + foo(5));
|
||||
2
static/js/ketcher2/node_modules/module-deps/example/files/xyz.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/example/files/xyz.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var foo = require('./foo');
|
||||
console.log('xyz: ' + foo(6));
|
||||
598
static/js/ketcher2/node_modules/module-deps/index.js
generated
vendored
Normal file
598
static/js/ketcher2/node_modules/module-deps/index.js
generated
vendored
Normal file
@ -0,0 +1,598 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var relativePath = require('cached-path-relative')
|
||||
|
||||
var browserResolve = require('browser-resolve');
|
||||
var nodeResolve = require('resolve');
|
||||
var detective = require('detective');
|
||||
var through = require('through2');
|
||||
var concat = require('concat-stream');
|
||||
var parents = require('parents');
|
||||
var combine = require('stream-combiner2');
|
||||
var duplexer = require('duplexer2');
|
||||
var xtend = require('xtend');
|
||||
var defined = require('defined');
|
||||
|
||||
var inherits = require('inherits');
|
||||
var Transform = require('readable-stream').Transform;
|
||||
|
||||
module.exports = Deps;
|
||||
inherits(Deps, Transform);
|
||||
|
||||
function Deps (opts) {
|
||||
var self = this;
|
||||
if (!(this instanceof Deps)) return new Deps(opts);
|
||||
Transform.call(this, { objectMode: true });
|
||||
|
||||
if (!opts) opts = {};
|
||||
|
||||
this.basedir = opts.basedir || process.cwd();
|
||||
this.persistentCache = opts.persistentCache || function (file, id, pkg, fallback, cb) {
|
||||
process.nextTick(function () {
|
||||
fallback(null, cb);
|
||||
});
|
||||
};
|
||||
this.cache = opts.cache;
|
||||
this.fileCache = opts.fileCache;
|
||||
this.pkgCache = opts.packageCache || {};
|
||||
this.pkgFileCache = {};
|
||||
this.pkgFileCachePending = {};
|
||||
this._emittedPkg = {};
|
||||
this.visited = {};
|
||||
this.walking = {};
|
||||
this.entries = [];
|
||||
this._input = [];
|
||||
|
||||
this.paths = opts.paths || process.env.NODE_PATH || '';
|
||||
if (typeof this.paths === 'string') {
|
||||
var delimiter = path.delimiter || (process.platform === 'win32' ? ';' : ':');
|
||||
this.paths = this.paths.split(delimiter);
|
||||
}
|
||||
this.paths = this.paths
|
||||
.filter(Boolean)
|
||||
.map(function (p) {
|
||||
return path.resolve(self.basedir, p);
|
||||
});
|
||||
|
||||
this.transforms = [].concat(opts.transform).filter(Boolean);
|
||||
this.globalTransforms = [].concat(opts.globalTransform).filter(Boolean);
|
||||
this.resolver = opts.resolve || browserResolve;
|
||||
this.options = xtend(opts);
|
||||
if (!this.options.modules) this.options.modules = {};
|
||||
|
||||
// If the caller passes options.expose, store resolved pathnames for exposed
|
||||
// modules in it. If not, set it anyway so it's defined later.
|
||||
if (!this.options.expose) this.options.expose = {};
|
||||
this.pending = 0;
|
||||
this.inputPending = 0;
|
||||
|
||||
var topfile = path.join(this.basedir, '__fake.js');
|
||||
this.top = {
|
||||
id: topfile,
|
||||
filename: topfile,
|
||||
paths: this.paths,
|
||||
basedir: this.basedir
|
||||
};
|
||||
}
|
||||
|
||||
Deps.prototype._isTopLevel = function (file) {
|
||||
var isTopLevel = this.entries.some(function (main) {
|
||||
var m = relativePath(path.dirname(main), file);
|
||||
return m.split(/[\\\/]/).indexOf('node_modules') < 0;
|
||||
});
|
||||
if (!isTopLevel) {
|
||||
var m = relativePath(this.basedir, file);
|
||||
isTopLevel = m.split(/[\\\/]/).indexOf('node_modules') < 0;
|
||||
}
|
||||
return isTopLevel;
|
||||
};
|
||||
|
||||
Deps.prototype._transform = function (row, enc, next) {
|
||||
var self = this;
|
||||
if (typeof row === 'string') {
|
||||
row = { file: row };
|
||||
}
|
||||
if (row.transform && row.global) {
|
||||
this.globalTransforms.push([ row.transform, row.options ]);
|
||||
return next();
|
||||
}
|
||||
else if (row.transform) {
|
||||
this.transforms.push([ row.transform, row.options ]);
|
||||
return next();
|
||||
}
|
||||
|
||||
self.pending ++;
|
||||
var basedir = defined(row.basedir, self.basedir);
|
||||
|
||||
if (row.entry !== false) {
|
||||
self.entries.push(path.resolve(basedir, row.file || row.id));
|
||||
}
|
||||
|
||||
self.lookupPackage(row.file, function (err, pkg) {
|
||||
if (err && self.options.ignoreMissing) {
|
||||
self.emit('missing', row.file, self.top);
|
||||
self.pending --;
|
||||
return next();
|
||||
}
|
||||
if (err) return self.emit('error', err)
|
||||
self.pending --;
|
||||
self._input.push({ row: row, pkg: pkg });
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Deps.prototype._flush = function () {
|
||||
var self = this;
|
||||
var files = {};
|
||||
self._input.forEach(function (r) {
|
||||
var w = r.row, f = files[w.file || w.id];
|
||||
if (f) {
|
||||
f.row.entry = f.row.entry || w.entry;
|
||||
var ex = f.row.expose || w.expose;
|
||||
f.row.expose = ex;
|
||||
if (ex && f.row.file === f.row.id && w.file !== w.id) {
|
||||
f.row.id = w.id;
|
||||
}
|
||||
}
|
||||
else files[w.file || w.id] = r;
|
||||
});
|
||||
|
||||
Object.keys(files).forEach(function (key) {
|
||||
var r = files[key];
|
||||
var pkg = r.pkg || {};
|
||||
var dir = r.row.file ? path.dirname(r.row.file) : self.basedir;
|
||||
if (!pkg.__dirname) pkg.__dirname = dir;
|
||||
self.walk(r.row, xtend(self.top, {
|
||||
filename: path.join(dir, '_fake.js')
|
||||
}));
|
||||
});
|
||||
if (this.pending === 0) this.push(null);
|
||||
this._ended = true;
|
||||
};
|
||||
|
||||
Deps.prototype.resolve = function (id, parent, cb) {
|
||||
var self = this;
|
||||
var opts = self.options;
|
||||
|
||||
if (xhas(self.cache, parent.id, 'deps', id)
|
||||
&& self.cache[parent.id].deps[id]) {
|
||||
var file = self.cache[parent.id].deps[id];
|
||||
var pkg = self.pkgCache[file];
|
||||
if (pkg) return cb(null, file, pkg);
|
||||
return self.lookupPackage(file, function (err, pkg) {
|
||||
cb(null, file, pkg);
|
||||
});
|
||||
}
|
||||
|
||||
parent.packageFilter = function (p, x) {
|
||||
var pkgdir = path.dirname(x);
|
||||
if (opts.packageFilter) p = opts.packageFilter(p, x);
|
||||
p.__dirname = pkgdir;
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
if (opts.extensions) parent.extensions = opts.extensions;
|
||||
if (opts.modules) parent.modules = opts.modules;
|
||||
|
||||
self.resolver(id, parent, function onresolve (err, file, pkg, fakePath) {
|
||||
if (err) return cb(err);
|
||||
if (!file) return cb(new Error(
|
||||
'module not found: "' + id + '" from file '
|
||||
+ parent.filename
|
||||
));
|
||||
|
||||
if (!pkg || !pkg.__dirname) {
|
||||
self.lookupPackage(file, function (err, p) {
|
||||
if (err) return cb(err);
|
||||
if (!p) p = {};
|
||||
if (!p.__dirname) p.__dirname = path.dirname(file);
|
||||
self.pkgCache[file] = p;
|
||||
onresolve(err, file, opts.packageFilter
|
||||
? opts.packageFilter(p, p.__dirname) : p,
|
||||
fakePath
|
||||
);
|
||||
});
|
||||
}
|
||||
else cb(err, file, pkg, fakePath);
|
||||
});
|
||||
};
|
||||
|
||||
Deps.prototype.readFile = function (file, id, pkg) {
|
||||
var self = this;
|
||||
if (xhas(this.fileCache, file)) {
|
||||
return toStream(this.fileCache[file]);
|
||||
}
|
||||
var rs = fs.createReadStream(file, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
rs.on('error', function (err) { self.emit('error', err) });
|
||||
this.emit('file', file, id);
|
||||
return rs;
|
||||
};
|
||||
|
||||
Deps.prototype.getTransforms = function (file, pkg, opts) {
|
||||
if (!opts) opts = {};
|
||||
var self = this;
|
||||
|
||||
var isTopLevel;
|
||||
if (opts.builtin || opts.inNodeModules) isTopLevel = false;
|
||||
else isTopLevel = this._isTopLevel(file);
|
||||
|
||||
var transforms = [].concat(isTopLevel ? this.transforms : [])
|
||||
.concat(getTransforms(pkg, {
|
||||
globalTransform: this.globalTransforms,
|
||||
transformKey: this.options.transformKey
|
||||
}))
|
||||
;
|
||||
if (transforms.length === 0) return through();
|
||||
|
||||
var pending = transforms.length;
|
||||
var streams = [];
|
||||
var input = through();
|
||||
var output = through();
|
||||
var dup = duplexer(input, output);
|
||||
|
||||
for (var i = 0; i < transforms.length; i++) (function (i) {
|
||||
makeTransform(transforms[i], function (err, trs) {
|
||||
if (err) return self.emit('error', err)
|
||||
streams[i] = trs;
|
||||
if (-- pending === 0) done();
|
||||
});
|
||||
})(i);
|
||||
return dup;
|
||||
|
||||
function done () {
|
||||
var middle = combine.apply(null, streams);
|
||||
middle.on('error', function (err) {
|
||||
err.message += ' while parsing file: ' + file;
|
||||
if (!err.filename) err.filename = file;
|
||||
self.emit('error', err);
|
||||
});
|
||||
input.pipe(middle).pipe(output);
|
||||
}
|
||||
|
||||
function makeTransform (tr, cb) {
|
||||
var trOpts = {};
|
||||
if (Array.isArray(tr)) {
|
||||
trOpts = tr[1] || {};
|
||||
tr = tr[0];
|
||||
}
|
||||
trOpts._flags = trOpts.hasOwnProperty('_flags') ? trOpts._flags : self.options;
|
||||
if (typeof tr === 'function') {
|
||||
var t = tr(file, trOpts);
|
||||
self.emit('transform', t, file);
|
||||
nextTick(cb, null, wrapTransform(t));
|
||||
}
|
||||
else {
|
||||
loadTransform(tr, trOpts, function (err, trs) {
|
||||
if (err) return cb(err);
|
||||
cb(null, wrapTransform(trs));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadTransform (id, trOpts, cb) {
|
||||
var params = { basedir: path.dirname(file) };
|
||||
nodeResolve(id, params, function nr (err, res, again) {
|
||||
if (err && again) return cb && cb(err);
|
||||
|
||||
if (err) {
|
||||
params.basedir = pkg.__dirname;
|
||||
return nodeResolve(id, params, function (e, r) {
|
||||
nr(e, r, true)
|
||||
});
|
||||
}
|
||||
|
||||
if (!res) return cb(new Error(
|
||||
'cannot find transform module ' + tr
|
||||
+ ' while transforming ' + file
|
||||
));
|
||||
|
||||
var r = require(res);
|
||||
if (typeof r !== 'function') {
|
||||
return cb(new Error(
|
||||
'Unexpected ' + typeof r + ' exported by the '
|
||||
+ JSON.stringify(res) + ' package. '
|
||||
+ 'Expected a transform function.'
|
||||
));
|
||||
}
|
||||
|
||||
var trs = r(file, trOpts);
|
||||
self.emit('transform', trs, file);
|
||||
cb(null, trs);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Deps.prototype.walk = function (id, parent, cb) {
|
||||
var self = this;
|
||||
var opts = self.options;
|
||||
this.pending ++;
|
||||
|
||||
var rec = {};
|
||||
var input;
|
||||
if (typeof id === 'object') {
|
||||
rec = xtend(id);
|
||||
if (rec.entry === false) delete rec.entry;
|
||||
id = rec.file || rec.id;
|
||||
input = true;
|
||||
this.inputPending ++;
|
||||
}
|
||||
|
||||
self.resolve(id, parent, function (err, file, pkg, fakePath) {
|
||||
// this is checked early because parent.modules is also modified
|
||||
// by this function.
|
||||
var builtin = has(parent.modules, id);
|
||||
|
||||
if (rec.expose) {
|
||||
// Set options.expose to make the resolved pathname available to the
|
||||
// caller. They may or may not have requested it, but it's harmless
|
||||
// to set this if they didn't.
|
||||
self.options.expose[rec.expose] =
|
||||
self.options.modules[rec.expose] = file;
|
||||
}
|
||||
if (pkg && !self._emittedPkg[pkg.__dirname]) {
|
||||
self._emittedPkg[pkg.__dirname] = true;
|
||||
self.emit('package', pkg);
|
||||
}
|
||||
|
||||
if (opts.postFilter && !opts.postFilter(id, file, pkg)) {
|
||||
if (--self.pending === 0) self.push(null);
|
||||
if (input) --self.inputPending;
|
||||
return cb && cb(null, undefined);
|
||||
}
|
||||
if (err && rec.source) {
|
||||
file = rec.file;
|
||||
|
||||
var ts = self.getTransforms(file, pkg);
|
||||
ts.pipe(concat(function (body) {
|
||||
rec.source = body.toString('utf8');
|
||||
fromSource(file, rec.source, pkg);
|
||||
}));
|
||||
return ts.end(rec.source);
|
||||
}
|
||||
if (err && self.options.ignoreMissing) {
|
||||
if (--self.pending === 0) self.push(null);
|
||||
if (input) --self.inputPending;
|
||||
self.emit('missing', id, parent);
|
||||
return cb && cb(null, undefined);
|
||||
}
|
||||
if (err) return self.emit('error', err);
|
||||
if (self.visited[file]) {
|
||||
if (-- self.pending === 0) self.push(null);
|
||||
if (input) --self.inputPending;
|
||||
return cb && cb(null, file);
|
||||
}
|
||||
self.visited[file] = true;
|
||||
|
||||
if (rec.source) {
|
||||
var ts = self.getTransforms(file, pkg);
|
||||
ts.pipe(concat(function (body) {
|
||||
rec.source = body.toString('utf8');
|
||||
fromSource(file, rec.source, pkg);
|
||||
}));
|
||||
return ts.end(rec.source);
|
||||
}
|
||||
|
||||
var c = self.cache && self.cache[file];
|
||||
if (c) return fromDeps(file, c.source, c.package, fakePath, Object.keys(c.deps));
|
||||
|
||||
self.persistentCache(file, id, pkg, persistentCacheFallback, function (err, c) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
return;
|
||||
}
|
||||
fromDeps(file, c.source, c.package, fakePath, Object.keys(c.deps));
|
||||
});
|
||||
|
||||
function persistentCacheFallback (dataAsString, cb) {
|
||||
var stream = dataAsString ? toStream(dataAsString) : self.readFile(file, id, pkg);
|
||||
stream
|
||||
.pipe(self.getTransforms(fakePath || file, pkg, {
|
||||
builtin: builtin,
|
||||
inNodeModules: parent.inNodeModules
|
||||
}))
|
||||
.pipe(concat(function (body) {
|
||||
var src = body.toString('utf8');
|
||||
var deps = getDeps(file, src);
|
||||
if (deps) {
|
||||
cb(null, {
|
||||
source: src,
|
||||
package: pkg,
|
||||
deps: deps.reduce(function (deps, dep) {
|
||||
deps[dep] = true;
|
||||
return deps;
|
||||
}, {})
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
function getDeps (file, src) {
|
||||
return rec.noparse ? [] : self.parseDeps(file, src);
|
||||
}
|
||||
|
||||
function fromSource (file, src, pkg, fakePath) {
|
||||
var deps = getDeps(file, src);
|
||||
if (deps) fromDeps(file, src, pkg, fakePath, deps);
|
||||
}
|
||||
|
||||
function fromDeps (file, src, pkg, fakePath, deps) {
|
||||
var p = deps.length;
|
||||
var resolved = {};
|
||||
|
||||
if (input) --self.inputPending;
|
||||
|
||||
(function resolve () {
|
||||
if (self.inputPending > 0) return setTimeout(resolve);
|
||||
deps.forEach(function (id) {
|
||||
if (opts.filter && !opts.filter(id)) {
|
||||
resolved[id] = false;
|
||||
if (--p === 0) done();
|
||||
return;
|
||||
}
|
||||
var isTopLevel = self._isTopLevel(fakePath || file);
|
||||
var current = {
|
||||
id: file,
|
||||
filename: file,
|
||||
paths: self.paths,
|
||||
package: pkg,
|
||||
inNodeModules: parent.inNodeModules || !isTopLevel
|
||||
};
|
||||
self.walk(id, current, function (err, r) {
|
||||
resolved[id] = r;
|
||||
if (--p === 0) done();
|
||||
});
|
||||
});
|
||||
if (deps.length === 0) done();
|
||||
})();
|
||||
|
||||
function done () {
|
||||
if (!rec.id) rec.id = file;
|
||||
if (!rec.source) rec.source = src;
|
||||
if (!rec.deps) rec.deps = resolved;
|
||||
if (!rec.file) rec.file = file;
|
||||
|
||||
if (self.entries.indexOf(file) >= 0) {
|
||||
rec.entry = true;
|
||||
}
|
||||
self.push(rec);
|
||||
|
||||
if (cb) cb(null, file);
|
||||
if (-- self.pending === 0) self.push(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Deps.prototype.parseDeps = function (file, src, cb) {
|
||||
if (this.options.noParse === true) return [];
|
||||
if (/\.json$/.test(file)) return [];
|
||||
|
||||
if (Array.isArray(this.options.noParse)
|
||||
&& this.options.noParse.indexOf(file) >= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try { var deps = detective(src) }
|
||||
catch (ex) {
|
||||
var message = ex && ex.message ? ex.message : ex;
|
||||
this.emit('error', new Error(
|
||||
'Parsing file ' + file + ': ' + message
|
||||
));
|
||||
return;
|
||||
}
|
||||
return deps;
|
||||
};
|
||||
|
||||
Deps.prototype.lookupPackage = function (file, cb) {
|
||||
var self = this;
|
||||
|
||||
var cached = this.pkgCache[file];
|
||||
if (cached) return nextTick(cb, null, cached);
|
||||
if (cached === false) return nextTick(cb, null, undefined);
|
||||
|
||||
var dirs = parents(file ? path.dirname(file) : self.basedir);
|
||||
|
||||
(function next () {
|
||||
if (dirs.length === 0) {
|
||||
self.pkgCache[file] = false;
|
||||
return cb(null, undefined);
|
||||
}
|
||||
var dir = dirs.shift();
|
||||
if (dir.split(/[\\\/]/).slice(-1)[0] === 'node_modules') {
|
||||
return cb(null, undefined);
|
||||
}
|
||||
|
||||
var pkgfile = path.join(dir, 'package.json');
|
||||
|
||||
var cached = self.pkgCache[pkgfile];
|
||||
if (cached) return nextTick(cb, null, cached);
|
||||
else if (cached === false) return next();
|
||||
|
||||
var pcached = self.pkgFileCachePending[pkgfile];
|
||||
if (pcached) return pcached.push(onpkg);
|
||||
pcached = self.pkgFileCachePending[pkgfile] = [];
|
||||
|
||||
fs.readFile(pkgfile, function (err, src) {
|
||||
if (err) return onpkg();
|
||||
try { var pkg = JSON.parse(src) }
|
||||
catch (err) {
|
||||
return onpkg(new Error([
|
||||
err + ' while parsing json file ' + pkgfile
|
||||
].join('')))
|
||||
}
|
||||
pkg.__dirname = dir;
|
||||
|
||||
self.pkgCache[pkgfile] = pkg;
|
||||
self.pkgCache[file] = pkg;
|
||||
onpkg(null, pkg);
|
||||
});
|
||||
|
||||
function onpkg (err, pkg) {
|
||||
if (self.pkgFileCachePending[pkgfile]) {
|
||||
var fns = self.pkgFileCachePending[pkgfile];
|
||||
delete self.pkgFileCachePending[pkgfile];
|
||||
fns.forEach(function (f) { f(err, pkg) });
|
||||
}
|
||||
if (err) cb(err)
|
||||
else if (pkg) cb(null, pkg)
|
||||
else {
|
||||
self.pkgCache[pkgfile] = false;
|
||||
next();
|
||||
}
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
function getTransforms (pkg, opts) {
|
||||
var trx = [];
|
||||
if (opts.transformKey) {
|
||||
var n = pkg;
|
||||
var keys = opts.transformKey;
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (n && typeof n === 'object') n = n[keys[i]];
|
||||
else break;
|
||||
}
|
||||
if (i === keys.length) {
|
||||
trx = [].concat(n).filter(Boolean);
|
||||
}
|
||||
}
|
||||
return trx.concat(opts.globalTransform || []);
|
||||
}
|
||||
|
||||
function nextTick (cb) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
process.nextTick(function () { cb.apply(null, args) });
|
||||
}
|
||||
|
||||
function xhas (obj) {
|
||||
if (!obj) return false;
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var key = arguments[i];
|
||||
if (!has(obj, key)) return false;
|
||||
obj = obj[key];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function toStream (dataAsString) {
|
||||
var tr = through();
|
||||
tr.push(dataAsString);
|
||||
tr.push(null);
|
||||
return tr;
|
||||
}
|
||||
|
||||
function has (obj, key) {
|
||||
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
function wrapTransform (tr) {
|
||||
if (typeof tr.read === 'function') return tr;
|
||||
var input = through(), output = through();
|
||||
input.pipe(tr).pipe(output);
|
||||
var wrapper = duplexer(input, output);
|
||||
tr.on('error', function (err) { wrapper.emit('error', err) });
|
||||
return wrapper;
|
||||
}
|
||||
84
static/js/ketcher2/node_modules/module-deps/package.json
generated
vendored
Normal file
84
static/js/ketcher2/node_modules/module-deps/package.json
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"_from": "module-deps@^4.0.8",
|
||||
"_id": "module-deps@4.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=",
|
||||
"_location": "/module-deps",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "module-deps@^4.0.8",
|
||||
"name": "module-deps",
|
||||
"escapedName": "module-deps",
|
||||
"rawSpec": "^4.0.8",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.8"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/browserify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz",
|
||||
"_shasum": "23215833f1da13fd606ccb8087b44852dcb821fd",
|
||||
"_spec": "module-deps@^4.0.8",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/browserify",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bin": {
|
||||
"module-deps": "bin/cmd.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/module-deps/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"JSONStream": "^1.0.3",
|
||||
"browser-resolve": "^1.7.0",
|
||||
"cached-path-relative": "^1.0.0",
|
||||
"concat-stream": "~1.5.0",
|
||||
"defined": "^1.0.0",
|
||||
"detective": "^4.0.0",
|
||||
"duplexer2": "^0.1.2",
|
||||
"inherits": "^2.0.1",
|
||||
"parents": "^1.0.0",
|
||||
"readable-stream": "^2.0.2",
|
||||
"resolve": "^1.1.3",
|
||||
"stream-combiner2": "^1.1.1",
|
||||
"subarg": "^1.0.0",
|
||||
"through2": "^2.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "walk the dependency graph to generate json output that can be fed into browser-pack",
|
||||
"devDependencies": {
|
||||
"browser-pack": "^5.0.0",
|
||||
"tap": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"homepage": "https://github.com/substack/module-deps",
|
||||
"keywords": [
|
||||
"dependency",
|
||||
"graph",
|
||||
"browser",
|
||||
"require",
|
||||
"module",
|
||||
"exports",
|
||||
"json"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "module-deps",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/module-deps.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "4.1.1"
|
||||
}
|
||||
289
static/js/ketcher2/node_modules/module-deps/readme.markdown
generated
vendored
Normal file
289
static/js/ketcher2/node_modules/module-deps/readme.markdown
generated
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
# module-deps
|
||||
|
||||
walk the dependency graph to generate json output that can be fed into
|
||||
[browser-pack](https://github.com/substack/browser-pack)
|
||||
|
||||
[](http://travis-ci.org/substack/module-deps)
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var mdeps = require('module-deps');
|
||||
var JSONStream = require('JSONStream');
|
||||
|
||||
var md = mdeps();
|
||||
md.pipe(JSONStream.stringify()).pipe(process.stdout);
|
||||
md.end({ file: __dirname + '/files/main.js' });
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
$ node example/deps.js
|
||||
[
|
||||
{"id":"/home/substack/projects/module-deps/example/files/main.js","source":"var foo = require('./foo');\nconsole.log('main: ' + foo(5));\n","entry":true,"deps":{"./foo":"/home/substack/projects/module-deps/example/files/foo.js"}}
|
||||
,
|
||||
{"id":"/home/substack/projects/module-deps/example/files/foo.js","source":"var bar = require('./bar');\n\nmodule.exports = function (n) {\n return n * 111 + bar(n);\n};\n","deps":{"./bar":"/home/substack/projects/module-deps/example/files/bar.js"}}
|
||||
,
|
||||
{"id":"/home/substack/projects/module-deps/example/files/bar.js","source":"module.exports = function (n) {\n return n * 100;\n};\n","deps":{}}
|
||||
]
|
||||
```
|
||||
|
||||
and you can feed this json data into
|
||||
[browser-pack](https://github.com/substack/browser-pack):
|
||||
|
||||
```
|
||||
$ node example/deps.js | browser-pack | node
|
||||
main: 1055
|
||||
```
|
||||
|
||||
# usage
|
||||
|
||||
```
|
||||
usage: module-deps [files]
|
||||
|
||||
generate json output from each entry file
|
||||
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var mdeps = require('module-deps')
|
||||
```
|
||||
|
||||
## var d = mdeps(opts={})
|
||||
|
||||
Return an object transform stream `d` that expects entry filenames or
|
||||
`{ id: ..., file: ... }` objects as input and produces objects for every
|
||||
dependency from a recursive module traversal as output.
|
||||
|
||||
Each file in `files` can be a string filename or a stream.
|
||||
|
||||
Optionally pass in some `opts`:
|
||||
|
||||
* `opts.transform` - a string or array of string transforms (see below)
|
||||
|
||||
* `opts.transformKey` - an array path of strings showing where to look in the
|
||||
package.json for source transformations. If falsy, don't look at the
|
||||
package.json at all.
|
||||
|
||||
* `opts.resolve` - custom resolve function using the
|
||||
`opts.resolve(id, parent, cb)` signature that
|
||||
[browser-resolve](https://github.com/shtylman/node-browser-resolve) has
|
||||
|
||||
* `opts.filter` - a function (id) to skip resolution of some module `id` strings.
|
||||
If defined, `opts.filter(id)` should return truthy for all the ids to include
|
||||
and falsey for all the ids to skip.
|
||||
|
||||
* `opts.postFilter` - a function (id, file, pkg) that gets called after `id` has
|
||||
been resolved. Return false to skip this file.
|
||||
|
||||
* `opts.packageFilter` - transform the parsed package.json contents before using
|
||||
the values. `opts.packageFilter(pkg, dir)` should return the new `pkg` object to
|
||||
use.
|
||||
|
||||
* `opts.noParse` - an array of absolute paths to not parse for dependencies. Use
|
||||
this for large dependencies like jquery or threejs which take forever to parse.
|
||||
|
||||
* `opts.cache` - an object mapping filenames to file objects to skip costly io
|
||||
|
||||
* `opts.packageCache` - an object mapping filenames to their parent package.json
|
||||
contents for browser fields, main entries, and transforms
|
||||
|
||||
* `opts.fileCache` - an object mapping filenames to raw source to avoid reading
|
||||
from disk.
|
||||
|
||||
* `opts.persistentCache` - a complex cache handler that allows async and persistent
|
||||
caching of data. A `persistentCache` needs to follow this interface:
|
||||
```
|
||||
function persistentCache (
|
||||
file, // the path to the file that is loaded
|
||||
id, // the id that is used to reference this file
|
||||
pkg, // the package that this file belongs to fallback
|
||||
fallback, // async fallback handler to be called if the cache doesn't hold the given file
|
||||
cb // callback handler that receives the cache data
|
||||
) {
|
||||
if (hasError()) {
|
||||
return cb(error) // Pass any error to the callback
|
||||
}
|
||||
|
||||
var fileData = fs.readFileSync(file)
|
||||
var key = keyFromFile(file, fileData)
|
||||
|
||||
if (db.has(key)) {
|
||||
return cb(null, {
|
||||
source: db.get(key).toString(),
|
||||
package: pkg, // The package for housekeeping
|
||||
deps: {
|
||||
'id': // id that is used to reference a required file
|
||||
'file' // file path to the required file
|
||||
}
|
||||
})
|
||||
}
|
||||
//
|
||||
// The fallback will process the file in case the file is not
|
||||
// in cache.
|
||||
//
|
||||
// Note that if your implementation doesn't need the file data
|
||||
// then you can pass `null` instead of the source and the fallback will
|
||||
// fetch the data by itself.
|
||||
//
|
||||
fallback(fileData, function (error, cacheableEntry) {
|
||||
if (error) {
|
||||
return cb(error)
|
||||
}
|
||||
db.addToCache(key, cacheableEntry)
|
||||
cb(null, cacheableEntry)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
* `opts.paths` - array of global paths to search. Defaults to splitting on `':'`
|
||||
in `process.env.NODE_PATH`
|
||||
|
||||
* `opts.ignoreMissing` - ignore files that failed to resolve
|
||||
|
||||
# input objects
|
||||
|
||||
Input objects should be string filenames or objects with these parameters:
|
||||
|
||||
* `row.file` - filename
|
||||
* `row.expose` - name to be exposed as
|
||||
* `row.noparse` when true, don't parse the file contents for dependencies
|
||||
|
||||
or objects can specify transforms:
|
||||
|
||||
* `row.transform` - string name, path, or function
|
||||
* `row.options` - transform options as an object
|
||||
* `row.global` - boolean, whether the transform is global
|
||||
|
||||
# events
|
||||
|
||||
## d.on('transform', function (tr, file) {})
|
||||
|
||||
Every time a transform is applied to a `file`, a `'transform'` event fires with
|
||||
the instantiated transform stream `tr`.
|
||||
|
||||
## d.on('file', function (file) {})
|
||||
|
||||
Every time a file is read, this event fires with the file path.
|
||||
|
||||
## d.on('missing', function (id, parent) {})
|
||||
|
||||
When `opts.ignoreMissing` is enabled, this event fires for each missing package.
|
||||
|
||||
## d.on('package', function (pkg) {})
|
||||
|
||||
Every time a package is read, this event fires. The directory name of the
|
||||
package is available in `pkg.__dirname`.
|
||||
|
||||
# transforms
|
||||
|
||||
module-deps can be configured to run source transformations on files before
|
||||
parsing them for `require()` calls. These transforms are useful if you want to
|
||||
compile a language like [coffeescript](http://coffeescript.org/) on the fly or
|
||||
if you want to load static assets into your bundle by parsing the AST for
|
||||
`fs.readFileSync()` calls.
|
||||
|
||||
If the transform is a function, it should take the `file` name as an argument
|
||||
and return a through stream that will be written file contents and should output
|
||||
the new transformed file contents.
|
||||
|
||||
If the transform is a string, it is treated as a module name that will resolve
|
||||
to a module that is expected to follow this format:
|
||||
|
||||
``` js
|
||||
var through = require('through2');
|
||||
module.exports = function (file, opts) { return through() };
|
||||
```
|
||||
|
||||
You don't necessarily need to use the
|
||||
[through2](https://github.com/rvagg/through2) module to create a
|
||||
readable/writable filter stream for transforming file contents, but this is an
|
||||
easy way to do it.
|
||||
|
||||
When you call `mdeps()` with an `opts.transform`, the transformations you
|
||||
specify will not be run for any files in node_modules/. This is because modules
|
||||
you include should be self-contained and not need to worry about guarding
|
||||
themselves against transformations that may happen upstream.
|
||||
|
||||
Modules can apply their own transformations by setting a transformation pipeline
|
||||
in their package.json at the `opts.transformKey` path. These transformations
|
||||
only apply to the files directly in the module itself, not to the module's
|
||||
dependants nor to its dependencies.
|
||||
|
||||
## package.json transformKey
|
||||
|
||||
Transform keys live at a configurable location in the package.json denoted by
|
||||
the `opts.transformKey` array.
|
||||
|
||||
For a transformKey of `['foo','bar']`, the transformKey can be a single string
|
||||
(`"fff"`):
|
||||
|
||||
``` json
|
||||
{
|
||||
"foo": {
|
||||
"bar": "fff"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
or an array of strings (`["fff","ggg"]`):
|
||||
|
||||
``` json
|
||||
{
|
||||
"foo": {
|
||||
"bar": ["fff","ggg"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you want to pass options to the transforms, you can use a 2-element array
|
||||
inside of the primary array. Here `fff` gets an options object with `{"x":3}`
|
||||
and `ggg` gets `{"y":4}`:
|
||||
|
||||
``` json
|
||||
{
|
||||
"foo": {
|
||||
"bar": [["fff",{"x":3}],["ggg",{"y":4}]]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Options sent to the module-deps constructor are also provided under
|
||||
`opts._flags`. These options are sometimes required if your transform
|
||||
needs to do something different when browserify is run in debug mode, for
|
||||
example.
|
||||
|
||||
# usage
|
||||
|
||||
```
|
||||
module-deps [FILES] OPTIONS
|
||||
|
||||
Generate json output for the entry point FILES.
|
||||
|
||||
OPTIONS are:
|
||||
|
||||
-t TRANSFORM Apply a TRANSFORM.
|
||||
-g TRANSFORM Apply a global TRANSFORM.
|
||||
|
||||
```
|
||||
|
||||
# install
|
||||
|
||||
With [npm](http://npmjs.org), to get the module do:
|
||||
|
||||
```
|
||||
npm install module-deps
|
||||
```
|
||||
|
||||
and to get the `module-deps` command do:
|
||||
|
||||
```
|
||||
npm install -g module-deps
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
23
static/js/ketcher2/node_modules/module-deps/test/bundle.js
generated
vendored
Normal file
23
static/js/ketcher2/node_modules/module-deps/test/bundle.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var JSONStream = require('JSONStream');
|
||||
var packer = require('browser-pack');
|
||||
var path = require('path');
|
||||
|
||||
test('bundle', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser();
|
||||
p.end(path.join(__dirname, '/files/main.js'));
|
||||
p.on('error', t.fail.bind(t));
|
||||
var pack = packer();
|
||||
|
||||
p.pipe(JSONStream.stringify()).pipe(pack);
|
||||
|
||||
var src = '';
|
||||
pack.on('data', function (buf) { src += buf });
|
||||
pack.on('end', function () {
|
||||
Function('console', src)({
|
||||
log: function (s) { t.equal(s, 'main: 1055') }
|
||||
});
|
||||
});
|
||||
});
|
||||
50
static/js/ketcher2/node_modules/module-deps/test/cache.js
generated
vendored
Normal file
50
static/js/ketcher2/node_modules/module-deps/test/cache.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
foo: path.join(__dirname, '/files/foo.js'),
|
||||
bar: path.join(__dirname, '/files/bar.js')
|
||||
};
|
||||
|
||||
var sources = {
|
||||
foo: 'notreal foo',
|
||||
bar: 'notreal bar'
|
||||
};
|
||||
|
||||
var cache = {};
|
||||
cache[files.foo] = {
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
};
|
||||
cache[files.bar] = {
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
};
|
||||
|
||||
test('uses cache', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ cache: cache });
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
54
static/js/ketcher2/node_modules/module-deps/test/cache_expose.js
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/module-deps/test/cache_expose.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
foo: path.join(__dirname, '/files/foo.js'),
|
||||
bar: path.join(__dirname, '/files/bar.js')
|
||||
};
|
||||
|
||||
var sources = {
|
||||
foo: 'notreal foo',
|
||||
bar: 'notreal bar'
|
||||
};
|
||||
|
||||
var cache = {};
|
||||
cache[files.foo] = {
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
};
|
||||
cache[files.bar] = {
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
};
|
||||
|
||||
test('cache preserves expose and entry', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ cache: cache });
|
||||
p.write({ id: files.bar, expose: 'bar2', entry: false });
|
||||
p.end({ id: 'foo', file: files.foo, entry: true, expose: 'foo2' });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
expose: 'foo2',
|
||||
entry: true,
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
expose: 'bar2',
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
47
static/js/ketcher2/node_modules/module-deps/test/cache_partial.js
generated
vendored
Normal file
47
static/js/ketcher2/node_modules/module-deps/test/cache_partial.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
foo: path.join(__dirname, '/files/foo.js'),
|
||||
bar: path.join(__dirname, '/files/bar.js')
|
||||
};
|
||||
|
||||
var sources = {
|
||||
foo: 'notreal foo',
|
||||
bar: fs.readFileSync(files.bar, 'utf8')
|
||||
};
|
||||
|
||||
var cache = {};
|
||||
cache[files.foo] = {
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
};
|
||||
|
||||
test('uses cache and reads from disk', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ cache: cache });
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
104
static/js/ketcher2/node_modules/module-deps/test/cache_partial_expose.js
generated
vendored
Normal file
104
static/js/ketcher2/node_modules/module-deps/test/cache_partial_expose.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var xtend = require('xtend');
|
||||
|
||||
var files = {
|
||||
abc: path.join(__dirname, '/expose/lib/abc.js'),
|
||||
xyz: path.join(__dirname, '/expose/lib/xyz.js'),
|
||||
foo: path.join(__dirname, '/expose/foo.js'),
|
||||
bar: path.join(__dirname, '/expose/bar.js'),
|
||||
main: path.join(__dirname, '/expose/main.js')
|
||||
};
|
||||
|
||||
var sources = Object.keys(files).reduce(function (acc, file) {
|
||||
acc[file] = fs.readFileSync(files[file], 'utf8');
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
var cache = {};
|
||||
cache[files.abc] = {
|
||||
source: sources.abc,
|
||||
deps: {}
|
||||
};
|
||||
cache[files.xyz] = {
|
||||
source: sources.xyz,
|
||||
deps: {'../foo': files.foo}
|
||||
};
|
||||
cache[files.foo] = {
|
||||
source: sources.foo,
|
||||
deps: {'./lib/abc': files.abc}
|
||||
};
|
||||
cache[files.bar] = {
|
||||
source: sources.bar,
|
||||
deps: {xyz: files.xyz}
|
||||
};
|
||||
cache[files.main] = {
|
||||
source: sources.main,
|
||||
deps: {
|
||||
abc: files.abc,
|
||||
xyz: files.xyz,
|
||||
'./bar': files.bar
|
||||
}
|
||||
};
|
||||
|
||||
test('preserves expose and entry with partial cache', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var partialCache = xtend(cache);
|
||||
delete partialCache[files.bar];
|
||||
|
||||
var p = parser({ cache: partialCache });
|
||||
p.write({ id: 'abc', file: files.abc, expose: 'abc' });
|
||||
p.write({ id: 'xyz', file: files.xyz, expose: 'xyz' });
|
||||
p.end({ id: 'main', file: files.main, entry: true });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row); });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {xyz: files.xyz}
|
||||
},
|
||||
{
|
||||
file: files.foo,
|
||||
id: files.foo,
|
||||
source: sources.foo,
|
||||
deps: {'./lib/abc': files.abc}
|
||||
},
|
||||
{
|
||||
id: 'abc',
|
||||
file: files.abc,
|
||||
source: sources.abc,
|
||||
deps: {},
|
||||
entry: true,
|
||||
expose: 'abc'
|
||||
},
|
||||
{
|
||||
id: 'main',
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
deps: {
|
||||
'./bar': files.bar,
|
||||
abc: files.abc,
|
||||
xyz: files.xyz
|
||||
},
|
||||
entry: true
|
||||
},
|
||||
{
|
||||
id: 'xyz',
|
||||
file: files.xyz,
|
||||
source: sources.xyz,
|
||||
deps: {'../foo': files.foo},
|
||||
entry: true,
|
||||
expose: 'xyz'
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
81
static/js/ketcher2/node_modules/module-deps/test/cache_persistent.js
generated
vendored
Normal file
81
static/js/ketcher2/node_modules/module-deps/test/cache_persistent.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var files = {
|
||||
foo: path.join(__dirname, '/files/foo.js'),
|
||||
bar: path.join(__dirname, '/files/bar.js')
|
||||
};
|
||||
|
||||
test('uses persistent cache', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({
|
||||
persistentCache: function (file, id, pkg, fallback, cb) {
|
||||
if (file === files.bar) {
|
||||
return fallback(null, cb)
|
||||
}
|
||||
cb(null, {
|
||||
source: 'file at ' + file + '@' + id,
|
||||
package: pkg,
|
||||
deps: { './bar': files.bar }
|
||||
})
|
||||
}
|
||||
});
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: fs.readFileSync(files.bar, 'utf8'),
|
||||
deps: {}
|
||||
},
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: 'file at ' + files.foo + '@' + files.foo,
|
||||
deps: { './bar': files.bar }
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
test('passes persistent cache error through', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({
|
||||
persistentCache: function (file, id, pkg, fallback, cb) {
|
||||
cb(new Error('foo'))
|
||||
}
|
||||
});
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
p.on('error', function (err) { t.equals(err.message, 'foo') });
|
||||
});
|
||||
|
||||
test('allow passing of the raw source as string', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({
|
||||
persistentCache: function (file, id, pkg, fallback, cb) {
|
||||
fallback(fs.readFileSync(files.bar, 'utf8'), cb)
|
||||
}
|
||||
});
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: fs.readFileSync(files.bar, 'utf8'),
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
19
static/js/ketcher2/node_modules/module-deps/test/cycle.js
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/module-deps/test/cycle.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var JSONStream = require('JSONStream');
|
||||
var packer = require('browser-pack');
|
||||
var concat = require('concat-stream');
|
||||
var path = require('path');
|
||||
|
||||
test('cycle', function (t) {
|
||||
t.plan(1);
|
||||
var p = mdeps();
|
||||
p.end(path.join(__dirname, '/cycle/main.js'));
|
||||
var pack = packer();
|
||||
|
||||
p.pipe(JSONStream.stringify()).pipe(pack).pipe(concat(function (src) {
|
||||
Function('console', src.toString('utf8'))({
|
||||
log: function (msg) { t.equal(msg, 333) }
|
||||
});
|
||||
}));
|
||||
});
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/cycle/bar.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/cycle/bar.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var foo = require('./foo.js');
|
||||
|
||||
module.exports = function (n) { return foo.p(n, 1) };
|
||||
4
static/js/ketcher2/node_modules/module-deps/test/cycle/foo.js
generated
vendored
Normal file
4
static/js/ketcher2/node_modules/module-deps/test/cycle/foo.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
var bar = require('./bar.js');
|
||||
|
||||
exports.ooo = function (n) { return n * bar(110) };
|
||||
exports.p = function (a, b) { return a + b }
|
||||
4
static/js/ketcher2/node_modules/module-deps/test/cycle/main.js
generated
vendored
Normal file
4
static/js/ketcher2/node_modules/module-deps/test/cycle/main.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
var foo = require('./foo.js');
|
||||
var bar = require('./bar.js');
|
||||
|
||||
console.log(foo.ooo(bar(2)));
|
||||
49
static/js/ketcher2/node_modules/module-deps/test/deps.js
generated
vendored
Normal file
49
static/js/ketcher2/node_modules/module-deps/test/deps.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
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('deps', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser();
|
||||
p.end({ file: files.main, entry: true });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.main,
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
entry: true,
|
||||
deps: { './foo': files.foo }
|
||||
},
|
||||
{
|
||||
id: files.foo,
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
20
static/js/ketcher2/node_modules/module-deps/test/dotdot.js
generated
vendored
Normal file
20
static/js/ketcher2/node_modules/module-deps/test/dotdot.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
|
||||
test('dotdot', function (t) {
|
||||
var expected = [
|
||||
path.join(__dirname, '/dotdot/index.js'),
|
||||
path.join(__dirname, '/dotdot/abc/index.js')
|
||||
];
|
||||
t.plan(expected.length);
|
||||
|
||||
var d = mdeps();
|
||||
d.end(path.join(__dirname, '/dotdot/abc/index.js'));
|
||||
|
||||
d.pipe(through.obj(function (row, enc, next) {
|
||||
t.deepEqual(row.file, expected.shift());
|
||||
next();
|
||||
}));
|
||||
});
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/dotdot/abc/index.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/dotdot/abc/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var x = require('..');
|
||||
console.log(x);
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/dotdot/index.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/dotdot/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = 'whatever'
|
||||
41
static/js/ketcher2/node_modules/module-deps/test/expose.js
generated
vendored
Normal file
41
static/js/ketcher2/node_modules/module-deps/test/expose.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
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('single id export', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser();
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/expose/bar.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/expose/bar.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('xyz');
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/expose/foo.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/expose/foo.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('./lib/abc');
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/expose/lib/abc.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/expose/lib/abc.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log('abc');
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/expose/lib/xyz.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/expose/lib/xyz.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
require('../foo');
|
||||
console.log('xyz');
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/expose/main.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/expose/main.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
require('abc');
|
||||
require('xyz');
|
||||
require('./bar');
|
||||
58
static/js/ketcher2/node_modules/module-deps/test/file_cache.js
generated
vendored
Normal file
58
static/js/ketcher2/node_modules/module-deps/test/file_cache.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var path = require('path');
|
||||
var through = require('through2');
|
||||
|
||||
var files = {
|
||||
foo: path.join(__dirname, '/files/foo.js'),
|
||||
bar: path.join(__dirname, '/files/bar.js')
|
||||
};
|
||||
|
||||
var sources = {
|
||||
foo: 'require("./bar"); var tongs;',
|
||||
bar: 'notreal tongs'
|
||||
};
|
||||
|
||||
var fileCache = {};
|
||||
fileCache[files.foo] = sources.foo;
|
||||
fileCache[files.bar] = sources.bar;
|
||||
|
||||
var specialReplace = function(input) {
|
||||
return input.replace(/tongs/g, 'tangs');
|
||||
};
|
||||
|
||||
test('uses file cache', function (t) {
|
||||
t.plan(1);
|
||||
var p = mdeps({
|
||||
fileCache: fileCache,
|
||||
transform: function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(specialReplace(String(buf)));
|
||||
next();
|
||||
});
|
||||
},
|
||||
transformKey: [ 'browserify', 'transform' ]
|
||||
});
|
||||
p.end({ id: 'foo', file: files.foo, entry: false });
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: 'foo',
|
||||
file: files.foo,
|
||||
source: specialReplace(sources.foo),
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: specialReplace(sources.bar),
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/bar.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/bar.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function (n) {
|
||||
return n * 100;
|
||||
};
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/extra.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/extra.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = 555
|
||||
10
static/js/ketcher2/node_modules/module-deps/test/files/filterable.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/module-deps/test/files/filterable.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
module.exports = {
|
||||
events: require('events'),
|
||||
fs : require('fs'),
|
||||
net : require('net'),
|
||||
http : require('http'),
|
||||
https : require('https'),
|
||||
dgram : require('dgram'),
|
||||
dns : require('dns')
|
||||
}
|
||||
5
static/js/ketcher2/node_modules/module-deps/test/files/foo.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/test/files/foo.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var bar = require('./bar');
|
||||
|
||||
module.exports = function (n) {
|
||||
return n * 111 + bar(n);
|
||||
};
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/files/main.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/files/main.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var foo = require('./foo');
|
||||
console.log('main: ' + foo(5));
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/one.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/one.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = 1
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/package.json
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/package.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"main": "one.js"
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/test.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/test.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
t.equal(require('./'), 2);
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/two.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/pkg_filter/two.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = 2
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/f.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/f.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x + BBB }
|
||||
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/main.js
generated
vendored
Normal file
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/main.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var f = require('./f.js');
|
||||
var m = require('m');
|
||||
var g = require('g');
|
||||
|
||||
t.equal(m(f(AAA)), 777, 'transformation scope');
|
||||
t.equal(g(3), 333, 'sub-transformation applied');
|
||||
t.equal(typeof GGG, 'undefined', 'GGG leak');
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/index.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x * GGG }
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/node_modules/insert-ggg/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/node_modules/insert-ggg/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/GGG/g, '111'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/package.json
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/g/package.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "index.js",
|
||||
"browserify": {
|
||||
"transform": "insert-ggg"
|
||||
}
|
||||
}
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/insert-aaa/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/insert-aaa/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/AAA/g, '5'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/insert-bbb/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/insert-bbb/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/BBB/g, '50'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/index.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var AAA = 200, BBB = 300;
|
||||
|
||||
module.exports = function (x) { return AAA + BBB + MMM + x }
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/node_modules/insert-mmm/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/node_modules/insert-mmm/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/MMM/g, '222'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/package.json
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_2dep_module/node_modules/m/package.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "index.js",
|
||||
"browserify": {
|
||||
"transform": "insert-mmm"
|
||||
}
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_global/main.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_global/main.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log(AAA + BBB + CCC + DDD + EEE + FFF);
|
||||
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_global/package.json
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_global/package.json
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"browserify": {
|
||||
"transform": [ "tr-a", "tr-b" ]
|
||||
}
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/f.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/f.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x + BBB }
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/XXX/g, '123'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/main.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/main.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var f = require('./f.js');
|
||||
var m = require('m');
|
||||
var g = require('g');
|
||||
|
||||
t.equal(m(f(AAA)), 555, 'transformation scope');
|
||||
t.equal(g(3), 333, 'sub-transformation applied');
|
||||
t.equal(typeof GGG, 'undefined', 'GGG leak');
|
||||
t.equal(XXX, 123, 'XXX');
|
||||
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/package.json
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/package.json
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"browserify": {
|
||||
"transform": [ "./xxx.js" ]
|
||||
}
|
||||
}
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/xxx.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_module/xxx.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/XXX/g, '123'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_no_entry/main.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_no_entry/main.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log(AAA)
|
||||
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/package.json
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/package.json
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"browserify": {
|
||||
"transform": [ "./xxx.js" ]
|
||||
}
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/subdir/main.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/subdir/main.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log(XXX * 3)
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/xxx.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_rel/xxx.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/XXX/g, '111'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/f.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/f.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x + BBB }
|
||||
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/main.js
generated
vendored
Normal file
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/main.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var f = require('./f.js');
|
||||
var m = require('m');
|
||||
var g = require('g');
|
||||
|
||||
t.equal(m(f(AAA)), 555, 'transformation scope');
|
||||
t.equal(g(3), 333, 'sub-transformation applied');
|
||||
t.equal(typeof GGG, 'undefined', 'GGG leak');
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/index.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x * GGG }
|
||||
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/package.json
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/package.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "index.js",
|
||||
"browserify": {
|
||||
"transform": "./tr_g.js"
|
||||
}
|
||||
}
|
||||
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/tr_g.js
generated
vendored
Normal file
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/g/tr_g.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var through = require('through2');
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/GGG/g, '111'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/m/index.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/node_modules/m/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var AAA = 200, BBB = 300;
|
||||
|
||||
module.exports = function (x) { return AAA + BBB + x }
|
||||
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/tr_a.js
generated
vendored
Normal file
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/tr_a.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var through = require('through2');
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/AAA/g, '5'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/tr_b.js
generated
vendored
Normal file
7
static/js/ketcher2/node_modules/module-deps/test/files/tr_sh/tr_b.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var through = require('through2');
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/BBB/g, '50'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/f.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/f.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var calc = require('algo').calc;
|
||||
|
||||
module.exports = function (x) { return calc(x); }
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/main.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/main.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var f = require('./f.js');
|
||||
|
||||
t.equal(f(14), 11, 'transformation scope');
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/index.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var decrement = require('./lib/decrement');
|
||||
|
||||
exports.calc = function (x) { return decrement(x) - GGG - GGG }
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/lib/decrement.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/lib/decrement.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function (x) { return x - GGG }
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/node_modules/insert-ggg/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/node_modules/insert-ggg/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/GGG/g, '1'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/package.json
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/module-deps/test/files/tr_whole_package/node_modules/algo/package.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "index.js",
|
||||
"browserify": {
|
||||
"transform": "insert-ggg"
|
||||
}
|
||||
}
|
||||
3
static/js/ketcher2/node_modules/module-deps/test/files/unicode/bar.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/module-deps/test/files/unicode/bar.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function (ñ) {
|
||||
return ñ * 100;
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/module-deps/test/files/unicode/foo.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/module-deps/test/files/unicode/foo.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var é = require('./bar');
|
||||
|
||||
module.exports = function (ñ) {
|
||||
return ñ * 111 + é(n);
|
||||
};
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/files/unicode/main.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/files/unicode/main.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var π = require('./foo');
|
||||
console.log('main: ' + foo(5));
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/files/xyz.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/files/xyz.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var foo = require('./foo');
|
||||
console.log('xyz: ' + foo(6));
|
||||
36
static/js/ketcher2/node_modules/module-deps/test/filter.js
generated
vendored
Normal file
36
static/js/ketcher2/node_modules/module-deps/test/filter.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
var test = require('tap').test;
|
||||
var path = require('path')
|
||||
var mdeps = require('../')
|
||||
|
||||
var core = ['events', 'util', 'dns', 'dgram', 'http', 'https', 'net', 'fs']
|
||||
|
||||
var collect = []
|
||||
|
||||
var entry = path.join(__dirname, 'files', 'filterable.js')
|
||||
|
||||
test('can filter core deps', function (t) {
|
||||
var p = mdeps({
|
||||
filter: function (e) {
|
||||
return !~core.indexOf(e)
|
||||
}
|
||||
})
|
||||
p.on('data', function (d) {
|
||||
collect.push(d)
|
||||
t.equal(d.id, entry)
|
||||
t.deepEqual(d.deps, {
|
||||
events: false,
|
||||
fs: false,
|
||||
net: false,
|
||||
http: false,
|
||||
https: false,
|
||||
dgram: false,
|
||||
dns: false
|
||||
})
|
||||
t.equal(d.entry, true)
|
||||
});
|
||||
p.on('end', function () {
|
||||
t.equal(collect.length, 1)
|
||||
t.end()
|
||||
});
|
||||
p.end(entry);
|
||||
})
|
||||
60
static/js/ketcher2/node_modules/module-deps/test/ignore_missing.js
generated
vendored
Normal file
60
static/js/ketcher2/node_modules/module-deps/test/ignore_missing.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
main: path.join(__dirname, '/ignore_missing/main.js'),
|
||||
other: path.join(__dirname, '/ignore_missing/other.js')
|
||||
};
|
||||
|
||||
var sources = Object.keys(files).reduce(function (acc, file) {
|
||||
acc[file] = fs.readFileSync(files[file], 'utf8');
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
test('ignoreMissing', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ignoreMissing: true});
|
||||
p.end({file: files.main, entry: true});
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.main,
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
entry: true,
|
||||
deps: { './other': files.other }
|
||||
},
|
||||
{
|
||||
id: files.other,
|
||||
file: files.other,
|
||||
source: sources.other,
|
||||
deps: { 'missingModule': undefined }
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
test('ignoreMissing off', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser();
|
||||
p.end({file: files.main, entry: true});
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('error', function (err) {
|
||||
t.match(
|
||||
String(err),
|
||||
/Cannot find module 'missingModule'/
|
||||
);
|
||||
});
|
||||
p.on('end', function () {
|
||||
t.fail('should have errored');
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/ignore_missing/main.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/ignore_missing/main.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('./other');
|
||||
1
static/js/ketcher2/node_modules/module-deps/test/ignore_missing/other.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/module-deps/test/ignore_missing/other.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('missingModule');
|
||||
52
static/js/ketcher2/node_modules/module-deps/test/ignore_missing_cache.js
generated
vendored
Normal file
52
static/js/ketcher2/node_modules/module-deps/test/ignore_missing_cache.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var files = {
|
||||
main: path.join(__dirname, '/ignore_missing/main.js'),
|
||||
other: path.join(__dirname, '/ignore_missing/other.js')
|
||||
};
|
||||
|
||||
var sources = Object.keys(files).reduce(function (acc, file) {
|
||||
acc[file] = fs.readFileSync(files[file], 'utf8');
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
var cache = {};
|
||||
cache[files.main] = {
|
||||
source: sources.main,
|
||||
deps: { './other': files.other }
|
||||
};
|
||||
cache[files.other] = {
|
||||
source: sources.other,
|
||||
deps: { 'missingModule': undefined }
|
||||
};
|
||||
|
||||
test('ignoreMissing with cache', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ cache: cache, ignoreMissing: true });
|
||||
p.end({file: files.main, entry: true});
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.main,
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
entry: true,
|
||||
deps: { './other': files.other }
|
||||
},
|
||||
{
|
||||
id: files.other,
|
||||
file: files.other,
|
||||
source: sources.other,
|
||||
deps: { 'missingModule': undefined }
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
8
static/js/ketcher2/node_modules/module-deps/test/node_modules/insert-www/index.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/module-deps/test/node_modules/insert-www/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var through = require('through2');
|
||||
|
||||
module.exports = function (file) {
|
||||
return through(function (buf, enc, next) {
|
||||
this.push(String(buf).replace(/WWW/g, '"world wide wow"'));
|
||||
next();
|
||||
});
|
||||
};
|
||||
43
static/js/ketcher2/node_modules/module-deps/test/noparse.js
generated
vendored
Normal file
43
static/js/ketcher2/node_modules/module-deps/test/noparse.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
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', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser({ noParse: [ files.foo ] });
|
||||
p.end(files.main);
|
||||
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,
|
||||
deps: { './foo': files.foo }
|
||||
},
|
||||
{
|
||||
id: files.foo,
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: {}
|
||||
}
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
39
static/js/ketcher2/node_modules/module-deps/test/noparse_row.js
generated
vendored
Normal file
39
static/js/ketcher2/node_modules/module-deps/test/noparse_row.js
generated
vendored
Normal file
@ -0,0 +1,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 }
|
||||
20
static/js/ketcher2/node_modules/module-deps/test/pkg.js
generated
vendored
Normal file
20
static/js/ketcher2/node_modules/module-deps/test/pkg.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var dirname = path.join(__dirname, '/pkg');
|
||||
|
||||
test('pkg', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var d = mdeps();
|
||||
d.on('package', function (pkg_) {
|
||||
var pkg = JSON.parse(fs.readFileSync(dirname + pkg_.dir + '/package.json'));
|
||||
pkg.__dirname = path.join(dirname, pkg_.dir);
|
||||
|
||||
t.deepEqual(pkg_, pkg);
|
||||
});
|
||||
d.end(path.join(__dirname, '/pkg/main.js'));
|
||||
d.resume();
|
||||
});
|
||||
2
static/js/ketcher2/node_modules/module-deps/test/pkg/main.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/module-deps/test/pkg/main.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
require('pkga');
|
||||
require('pkgb');
|
||||
4
static/js/ketcher2/node_modules/module-deps/test/pkg/package.json
generated
vendored
Normal file
4
static/js/ketcher2/node_modules/module-deps/test/pkg/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"dir": "",
|
||||
"main": "index.js"
|
||||
}
|
||||
26
static/js/ketcher2/node_modules/module-deps/test/pkg_filter.js
generated
vendored
Normal file
26
static/js/ketcher2/node_modules/module-deps/test/pkg_filter.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var JSONStream = require('JSONStream');
|
||||
var packer = require('browser-pack');
|
||||
var concat = require('concat-stream');
|
||||
var path = require('path');
|
||||
|
||||
test('pkg filter', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var p = mdeps({
|
||||
packageFilter: function (pkg) {
|
||||
t.equal(pkg.main, 'one.js');
|
||||
pkg.main = 'two.js'
|
||||
return pkg;
|
||||
}
|
||||
});
|
||||
p.end(path.join(__dirname, '/files/pkg_filter/test.js'));
|
||||
|
||||
var pack = packer();
|
||||
p.pipe(JSONStream.stringify()).pipe(pack);
|
||||
|
||||
pack.pipe(concat(function (src) {
|
||||
Function('t', src)(t);
|
||||
}));
|
||||
});
|
||||
24
static/js/ketcher2/node_modules/module-deps/test/row_expose.js
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/module-deps/test/row_expose.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
|
||||
// Test that p.options.expose is defined and that the row is properly exposed
|
||||
// (resolved to the absolute pathname corresponding to the `file` value passed
|
||||
// in the row, and set in opts.expose).
|
||||
test('row is exposed', function (t) {
|
||||
t.plan(1);
|
||||
var common_path = path.join(__dirname, '/files/main');
|
||||
var opts = { expose: {} };
|
||||
var p = parser(opts);
|
||||
// Note pathname without extension.
|
||||
p.end({ file: common_path, expose: "whatever" });
|
||||
p.on('error', t.fail.bind(t));
|
||||
|
||||
p.pipe(through.obj());
|
||||
|
||||
p.on('end', function () {
|
||||
// Note pathname with extension.
|
||||
t.equal(opts.expose.whatever, common_path + '.js');
|
||||
});
|
||||
});
|
||||
32
static/js/ketcher2/node_modules/module-deps/test/row_expose_name_is_file_transform.js
generated
vendored
Normal file
32
static/js/ketcher2/node_modules/module-deps/test/row_expose_name_is_file_transform.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
|
||||
// test that (non global) transforms are applied to an exposed module, where in the
|
||||
// exposed name is identical to the file path.
|
||||
test('row is exposed with a name equal to the path, and transformed', function (t) {
|
||||
t.plan(2);
|
||||
var exposed_path = path.join(__dirname, '/files/main.js');
|
||||
var found_exposed_path = false;
|
||||
var opts = {
|
||||
expose: {},
|
||||
transform: function(file) {
|
||||
if (file === exposed_path) {
|
||||
found_exposed_path = true;
|
||||
}
|
||||
return through();
|
||||
}
|
||||
};
|
||||
|
||||
var p = parser(opts);
|
||||
p.end({ file: exposed_path, expose: exposed_path });
|
||||
p.on('error', t.fail.bind(t));
|
||||
|
||||
p.pipe(through.obj());
|
||||
|
||||
p.on('end', function () {
|
||||
t.equal(opts.expose[exposed_path], exposed_path);
|
||||
t.ok(found_exposed_path);
|
||||
});
|
||||
});
|
||||
31
static/js/ketcher2/node_modules/module-deps/test/row_expose_transform.js
generated
vendored
Normal file
31
static/js/ketcher2/node_modules/module-deps/test/row_expose_transform.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
|
||||
// test that (non global) transforms are applied to an exposed module
|
||||
test('row is exposed and transformed', function (t) {
|
||||
t.plan(2);
|
||||
var exposed_path = path.join(__dirname, '/files/main.js');
|
||||
var found_exposed_path = false;
|
||||
var opts = {
|
||||
expose: {},
|
||||
transform: function(file) {
|
||||
if (file === exposed_path) {
|
||||
found_exposed_path = true;
|
||||
}
|
||||
return through();
|
||||
}
|
||||
};
|
||||
|
||||
var p = parser(opts);
|
||||
p.end({ file: exposed_path, expose: "whatever" });
|
||||
p.on('error', t.fail.bind(t));
|
||||
|
||||
p.pipe(through.obj());
|
||||
|
||||
p.on('end', function () {
|
||||
t.equal(opts.expose.whatever, exposed_path);
|
||||
t.ok(found_exposed_path);
|
||||
});
|
||||
});
|
||||
61
static/js/ketcher2/node_modules/module-deps/test/source.js
generated
vendored
Normal file
61
static/js/ketcher2/node_modules/module-deps/test/source.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
var parser = require('../');
|
||||
var test = require('tap').test;
|
||||
var fs = require('fs');
|
||||
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'),
|
||||
extra: path.join(__dirname, '/files/extra.js')
|
||||
};
|
||||
var sources = {
|
||||
foo: fs.readFileSync(files.foo, 'utf8'),
|
||||
bar: fs.readFileSync(files.bar, 'utf8'),
|
||||
extra: fs.readFileSync(files.extra, 'utf8'),
|
||||
main: "console.log(require('./foo')(5)); require('./extra.js')"
|
||||
};
|
||||
|
||||
test('source', function (t) {
|
||||
t.plan(1);
|
||||
var p = parser();
|
||||
p.end({
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
entry: true
|
||||
});
|
||||
|
||||
var rows = [];
|
||||
p.on('data', function (row) { rows.push(row) });
|
||||
p.on('end', function () {
|
||||
t.same(rows.sort(cmp), [
|
||||
{
|
||||
id: files.main,
|
||||
file: files.main,
|
||||
source: sources.main,
|
||||
entry: true,
|
||||
deps: { './foo': files.foo, './extra.js': files.extra }
|
||||
},
|
||||
{
|
||||
id: files.foo,
|
||||
file: files.foo,
|
||||
source: sources.foo,
|
||||
deps: { './bar': files.bar }
|
||||
},
|
||||
{
|
||||
id: files.bar,
|
||||
file: files.bar,
|
||||
source: sources.bar,
|
||||
deps: {}
|
||||
},
|
||||
{
|
||||
id: files.extra,
|
||||
file: files.extra,
|
||||
source: sources.extra,
|
||||
deps: {}
|
||||
},
|
||||
].sort(cmp));
|
||||
});
|
||||
});
|
||||
|
||||
function cmp (a, b) { return a.id < b.id ? -1 : 1 }
|
||||
23
static/js/ketcher2/node_modules/module-deps/test/tr_2dep_module.js
generated
vendored
Normal file
23
static/js/ketcher2/node_modules/module-deps/test/tr_2dep_module.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var JSONStream = require('JSONStream');
|
||||
var packer = require('browser-pack');
|
||||
var path = require('path');
|
||||
|
||||
test('transform', function (t) {
|
||||
t.plan(3);
|
||||
var p = mdeps({
|
||||
transform: [ 'insert-aaa', 'insert-bbb' ],
|
||||
transformKey: [ 'browserify', 'transform' ]
|
||||
});
|
||||
p.end(path.join(__dirname, '/files/tr_2dep_module/main.js'));
|
||||
var pack = packer();
|
||||
|
||||
p.pipe(JSONStream.stringify()).pipe(pack);
|
||||
|
||||
var src = '';
|
||||
pack.on('data', function (buf) { src += buf });
|
||||
pack.on('end', function () {
|
||||
Function('t', src)(t);
|
||||
});
|
||||
});
|
||||
21
static/js/ketcher2/node_modules/module-deps/test/tr_err.js
generated
vendored
Normal file
21
static/js/ketcher2/node_modules/module-deps/test/tr_err.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
var JSONStream = require('JSONStream');
|
||||
var packer = require('browser-pack');
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
|
||||
test('transform', function (t) {
|
||||
t.plan(1);
|
||||
var p = mdeps({
|
||||
transform: function (file) {
|
||||
return through(function () {
|
||||
this.emit('error', new Error('rawr'));
|
||||
});
|
||||
}
|
||||
});
|
||||
p.on('error', function (err) {
|
||||
t.ok(/tr_sh[\\\/]main\.js/.test(err));
|
||||
});
|
||||
p.end(path.join(__dirname, '/files/tr_sh/main.js'));
|
||||
});
|
||||
44
static/js/ketcher2/node_modules/module-deps/test/tr_flags.js
generated
vendored
Normal file
44
static/js/ketcher2/node_modules/module-deps/test/tr_flags.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
var through = require('through2');
|
||||
var mdeps = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('--debug passed to transforms', function (t) {
|
||||
var empty = require.resolve('./tr_flags/empty.js');
|
||||
|
||||
t.plan(5);
|
||||
|
||||
var p
|
||||
[true, false].forEach(function(debug) {
|
||||
p = mdeps({
|
||||
debug: debug,
|
||||
transform: function (file, opts) {
|
||||
t.equal(opts._flags.debug, debug, 'debug: ' + debug);
|
||||
return through();
|
||||
}
|
||||
})
|
||||
p.on('error', function (err) { return t.fail(err.message) })
|
||||
p.end(empty);
|
||||
|
||||
p = mdeps({ debug: debug })
|
||||
p.write({
|
||||
transform: function (file, opts) {
|
||||
t.equal(opts._flags.debug, debug, 'debug: ' + debug);
|
||||
return through();
|
||||
},
|
||||
options: {}
|
||||
})
|
||||
p.on('error', function (err) { return t.fail(err.message) })
|
||||
p.end(empty);
|
||||
});
|
||||
|
||||
p = mdeps({ debug: true })
|
||||
p.write({
|
||||
transform: function (file, opts) {
|
||||
t.equal(opts._flags, Infinity, 'transform arguments are preserved');
|
||||
return through();
|
||||
},
|
||||
options: { _flags: Infinity }
|
||||
})
|
||||
p.on('error', function (err) { return t.fail(err.message) })
|
||||
p.end(empty);
|
||||
});
|
||||
0
static/js/ketcher2/node_modules/module-deps/test/tr_flags/empty.js
generated
vendored
Normal file
0
static/js/ketcher2/node_modules/module-deps/test/tr_flags/empty.js
generated
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user