UNPKG

subprojects

Version:

Simple management tool for dependent subprojects in Node.js environment.

24 lines (21 loc) 686 B
function init(config) { if (!config) throw new Error('Subprojects config is required!'); var mod, mod_load = global._module_load; if (mod_load) { mod = mod_load('module'); } else { mod = require('module'); global._module_load = mod_load = mod._load; } if (typeof config === 'string') config = mod_load(config); mod._load = function(request, parent, isMain) { if (config[request]) return mod_load(config[request], parent, isMain); return mod_load(request, parent, isMain); }; } exports.init = init; if (process.env.NODE_LOCAL_SUBPROJECTS) init(process.env.NODE_LOCAL_SUBPROJECTS);