Skip to content

Commit

Permalink
fixed plugin-specific configs and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
unscriptable committed Oct 24, 2012
1 parent 61e58a3 commit 5c03480
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/curl.js
Expand Up @@ -490,7 +490,7 @@
},

moreConfig: function (cfg, prevCfg) {
var newCfg, pluginCfgs, p;
var newCfg, pluginCfgs, p, absId;

if (!prevCfg) prevCfg = {};
newCfg = beget(prevCfg, cfg);
Expand All @@ -505,10 +505,6 @@
newCfg.pathMap = beget(prevCfg.pathMap);
pluginCfgs = cfg['plugins'] || {};
newCfg.plugins = beget(prevCfg.plugins);
for (p in pluginCfgs) {
newCfg.plugins[core.toAbsId(p, '', newCfg)] = pluginCfgs[p];
}
pluginCfgs = newCfg.plugins;

// temporary arrays of paths. this will be converted to
// a regexp for fast path parsing.
Expand Down Expand Up @@ -581,6 +577,14 @@
fixAndPushPaths(cfg['packages'], true);
fixAndPushPaths(cfg['paths'], false);

// process plugins after packages in case we already perform an
// id transform on a plugin (i.e. it's a package.main)
for (p in pluginCfgs) {
var absId = core.toAbsId(p + '!', '', newCfg);
newCfg.plugins[absId.substr(0, absId.length - 1)] = pluginCfgs[p];
}
pluginCfgs = newCfg.plugins;

// create search regex for each path map
for (p in pluginCfgs) {
// inherit full config
Expand Down
3 changes: 1 addition & 2 deletions test/packages.html
Expand Up @@ -34,8 +34,7 @@
{ name: 'plugin', location: '', main: '../main-plugin', config: { pkgValue: 27 } }
],
plugins: {
// TODO: this should be "plugin", not "main-plugin"
'main-plugin': { testValue: 42 }
'plugin': { testValue: 42 }
}
};

Expand Down
6 changes: 1 addition & 5 deletions test/pluginConfig.html
Expand Up @@ -20,12 +20,8 @@
stuff: 'test/stuff'
},
plugins: {
'test/support/fake': {
'fake': {
testValue: testValue
// TODO: this should be "fake" and not "test/support/fake"
// }
// 'fake': {
// testValue: testValue
}
}
},
Expand Down

0 comments on commit 5c03480

Please sign in to comment.