Comparing version 0.7.3 to 0.8.0
@@ -56,8 +56,8 @@ makeInstaller = function (options) { | ||
Module.prototype.resolve = function (id) { | ||
return this.require.resolve(id); | ||
}; | ||
install.Module = Module; | ||
Module.prototype.get = function (key) { | ||
return this.exports[key]; | ||
}; | ||
function getOwn(obj, key) { | ||
@@ -80,6 +80,6 @@ return hasOwn.call(obj, key) && obj[key]; | ||
function makeRequire(file) { | ||
function require(id, setters) { | ||
function require(id) { | ||
var result = fileResolve(file, id); | ||
if (result) { | ||
return fileEvaluate(result, file.m, setters); | ||
return fileEvaluate(result, file.m); | ||
} | ||
@@ -134,3 +134,3 @@ | ||
function fileEvaluate(file, parentModule, setters) { | ||
function fileEvaluate(file, parentModule) { | ||
var contents = file && file.c; | ||
@@ -153,3 +153,3 @@ var module = file.m; | ||
contents( | ||
file.r = file.r || makeRequire(file), | ||
module.require = module.require || makeRequire(file), | ||
module.exports = {}, | ||
@@ -165,3 +165,5 @@ module, | ||
runModuleSetters(module, setters); | ||
if (isFunction(module.runModuleSetters)) { | ||
module.runModuleSetters(); | ||
} | ||
@@ -171,28 +173,2 @@ return module.exports; | ||
function runModuleSetters(module, setters) { | ||
var ms = module.setters = module.setters || {}; | ||
if (isObject(setters)) { | ||
Object.keys(setters).forEach(function (key) { | ||
ms[key] = ms[key] || []; | ||
ms[key].push(setters[key]); | ||
}); | ||
} | ||
Object.keys(ms).forEach(function (key) { | ||
var value = module.get(key); | ||
ms[key].forEach(function (setter) { | ||
if (isFunction(setter) && | ||
! (hasOwn.call(setter, "last") && | ||
value === setter.last)) { | ||
setter(setter.last = value); | ||
} | ||
}); | ||
}); | ||
if (module.loaded) { | ||
delete module.setters; | ||
} | ||
} | ||
function fileIsDirectory(file) { | ||
@@ -199,0 +175,0 @@ return file && isObject(file.c); |
@@ -1,1 +0,1 @@ | ||
makeInstaller=function(n){function r(n,r){return o(n)&&(d(b,n,r),i(j)&&j(g)),g}function t(n){this.id=n,this.children=[]}function e(n,r){return E.call(n,r)&&n[r]}function o(n){return n&&"object"==typeof n}function i(n){return"function"==typeof n}function u(n){return"string"==typeof n}function c(n){function r(r,t){var e=m(n,r);if(e)return a(e,n.m,t);var o=new Error("Cannot find module '"+r+"'");if(i(k))return k(r,n.m.id,o);throw o}return r.resolve=function(r){var t=m(n,r);if(t)return t.m.id;throw new Error("Cannot find module '"+r+"'")},r}function f(n,r){var e=this;e.p=r=r||null,e.m=new t(n)}function a(n,r,t){var e=n&&n.c,o=n.m;if(!E.call(o,"exports")){if(r){o.parent=r;var u=r.children;Array.isArray(u)&&u.push(o)}i(o.useNode)&&o.useNode()||e(n.r=n.r||c(n),o.exports={},o,n.m.id,n.p.m.id),o.loaded=!0}return s(o,t),o.exports}function s(n,r){var t=n.setters=n.setters||{};o(r)&&Object.keys(r).forEach(function(n){t[n]=t[n]||[],t[n].push(r[n])}),Object.keys(t).forEach(function(r){var e=n.get(r);t[r].forEach(function(n){!i(n)||E.call(n,"last")&&e===n.last||n(n.last=e)})}),n.loaded&&delete n.setters}function l(n){return n&&o(n.c)}function d(n,r,t){if(Array.isArray(r)){var c=[];r.forEach(function(n){u(n)?c.push(n):i(n)&&(r=n)}),i(r)?r.d=c:r=null}else i(r)?r.d=r.d||[]:u(r)||o(r)||(r=null);r&&(n.c=n.c||(o(r)?{}:r),o(r)&&l(n)&&Object.keys(r).forEach(function(o){if(".."===o)i=n.p;else{var i=e(n.c,o);i||(i=n.c[o]=new f(n.m.id.replace(/\/*$/,"/")+o,n),i.o=t)}d(i,r[o],t)}))}function p(n){return n.o&&n.o.extensions||x}function h(n,r,t){for(;n&&!l(n);)n=n.p;if(!n||!r||"."===r)return n;if(".."===r)return n.p;var o=e(n.c,r);if(t&&(!o||l(o)))for(var i=0;i<t.length;++i){var u=e(n.c,r+t[i]);if(u)return u}return o}function v(n,r,t){var e=r.split("/");return e.every(function(r,o){return n=o<e.length-1?h(n,r):h(n,r,t)}),n}function m(n,r,t){var e=p(n);for(n="/"===r.charAt(0)?v(b,r,e):"."===r.charAt(0)?v(n,r,e):y(n,r,e);l(n);){if(t=t||[],t.indexOf(n)<0){t.push(n);var o=h(n,"package.json"),i=o&&a(o).main;if(u(i)&&(n=v(n,i,e)||m(n,i,t)))continue}n=h(n,"index.js")}return n&&u(n.c)&&(n=m(n,n.c,t)),n}function y(n,r,t){if(i(w)&&(r=w(r,n.m.id)),u(r)){for(var e;n&&!e;n=n.p)e=l(n)&&v(n,"node_modules/"+r,t);return e}}n=n||{};var x=n.extensions||[".js",".json"],j=n.onInstall,w=n.override,k=n.fallback,E={}.hasOwnProperty,b=new f("/",new f("/..")),g=c(b);return r.Module=t,t.prototype.get=function(n){return this.exports[n]},r},"object"==typeof exports&&(exports.makeInstaller=makeInstaller); | ||
makeInstaller=function(r){function n(r,n){return o(r)&&(l(A,r,n),i(w)&&w(b)),b}function e(r){this.id=r,this.children=[]}function t(r,n){return k.call(r,n)&&r[n]}function o(r){return r&&"object"==typeof r}function i(r){return"function"==typeof r}function u(r){return"string"==typeof r}function f(r){function n(n){var e=h(r,n);if(e)return a(e,r.m);var t=new Error("Cannot find module '"+n+"'");if(i(j))return j(n,r.m.id,t);throw t}return n.resolve=function(n){var e=h(r,n);if(e)return e.m.id;throw new Error("Cannot find module '"+n+"'")},n}function c(r,n){var t=this;t.p=n=n||null,t.m=new e(r)}function a(r,n){var e=r&&r.c,t=r.m;if(!k.call(t,"exports")){if(n){t.parent=n;var o=n.children;Array.isArray(o)&&o.push(t)}i(t.useNode)&&t.useNode()||e(t.require=t.require||f(r),t.exports={},t,r.m.id,r.p.m.id),t.loaded=!0}return i(t.runModuleSetters)&&t.runModuleSetters(),t.exports}function s(r){return r&&o(r.c)}function l(r,n,e){if(Array.isArray(n)){var f=[];n.forEach(function(r){u(r)?f.push(r):i(r)&&(n=r)}),i(n)?n.d=f:n=null}else i(n)?n.d=n.d||[]:u(n)||o(n)||(n=null);n&&(r.c=r.c||(o(n)?{}:n),o(n)&&s(r)&&Object.keys(n).forEach(function(o){if(".."===o)i=r.p;else{var i=t(r.c,o);i||(i=r.c[o]=new c(r.m.id.replace(/\/*$/,"/")+o,r),i.o=e)}l(i,n[o],e)}))}function d(r){return r.o&&r.o.extensions||y}function p(r,n,e){for(;r&&!s(r);)r=r.p;if(!r||!n||"."===n)return r;if(".."===n)return r.p;var o=t(r.c,n);if(e&&(!o||s(o)))for(var i=0;i<e.length;++i){var u=t(r.c,n+e[i]);if(u)return u}return o}function v(r,n,e){var t=n.split("/");return t.every(function(n,o){return r=o<t.length-1?p(r,n):p(r,n,e)}),r}function h(r,n,e){var t=d(r);for(r="/"===n.charAt(0)?v(A,n,t):"."===n.charAt(0)?v(r,n,t):m(r,n,t);s(r);){if(e=e||[],e.indexOf(r)<0){e.push(r);var o=p(r,"package.json"),i=o&&a(o).main;if(u(i)&&(r=v(r,i,t)||h(r,i,e)))continue}r=p(r,"index.js")}return r&&u(r.c)&&(r=h(r,r.c,e)),r}function m(r,n,e){if(i(x)&&(n=x(n,r.m.id)),u(n)){for(var t;r&&!t;r=r.p)t=s(r)&&v(r,"node_modules/"+n,e);return t}}r=r||{};var y=r.extensions||[".js",".json"],w=r.onInstall,x=r.override,j=r.fallback,k={}.hasOwnProperty,A=new c("/",new c("/..")),b=f(A);return e.prototype.resolve=function(r){return this.require.resolve(r)},n.Module=e,n},"object"==typeof exports&&(exports.makeInstaller=makeInstaller); |
@@ -18,3 +18,3 @@ { | ||
], | ||
"version": "0.7.3", | ||
"version": "0.8.0", | ||
"license": "MIT", | ||
@@ -35,3 +35,4 @@ "homepage": "http://github.com/benjamn/install", | ||
"mocha": "^2.3.3", | ||
"uglifyjs": "^2.4.10" | ||
"uglifyjs": "^2.4.10", | ||
"reify": "^0.1.9" | ||
}, | ||
@@ -38,0 +39,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
421408
4
1043