UNPKG

hem

Version:

stitches CommonJS, and ties up other lose ends of web-app development.

68 lines (62 loc) 1.89 kB
(function(/*! Stitch !*/) { if (!this.specs) { var modules = {}, cache = {}, require = function(name, root) { var path = expand(root, name), indexPath = expand(path, './index'), module, fn; module = cache[path] || cache[indexPath] if (module) { return module.exports; } else if (fn = modules[path] || modules[path = indexPath]) { module = {id: path, exports: {}}; try { cache[path] = module; fn(module.exports, function(name) { return require(name, dirname(path)); }, module); return module.exports; } catch (err) { delete cache[path]; throw err; } } else { throw 'module ' + name + ' not found'; } }, expand = function(root, name) { var results = [], parts, part; if (/^..?(\/|$)/.test(name)) { parts = [root, name].join('/').split('/'); } else { parts = name.split('/'); } for (var i = 0, length = parts.length; i < length; i++) { part = parts[i]; if (part == '..') { results.pop(); } else if (part != '.' && part != '') { results.push(part); } } return results.join('/'); }, dirname = function(path) { return path.split('/').slice(0, -1).join('/'); }; this.specs = function(name) { return require(name, ''); } this.specs.define = function(bundle) { for (var key in bundle) modules[key] = bundle[key]; }; this.specs.modules = modules; this.specs.cache = cache; } return this.specs.define; }).call(this)({ }); require('lib/setup')// HEM: load in specs from test js file var onlyMatchingModules = ""; for (var key in specs.modules) { if (onlyMatchingModules && key.indexOf(onlyMatchingModules) == -1) { continue; } specs(key); }