Skip to content

Commit

Permalink
overrides to store as upgraded config
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Oct 5, 2015
1 parent 1310724 commit 9e3dde7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,9 @@ function logInstall(name, target, resolution, linked, options) {
}

if (options.dev)
verb += 'for dev ';
verb += (verb ? 'd' : 'D') + 'ev dependency ';
else if (options.peer)
verb += 'peer ';
verb += (verb ? 'p' : 'P') + 'eer ';

var actual = resolution.version;
if (resolution.package != target.package)
Expand Down
68 changes: 37 additions & 31 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,42 +299,45 @@ function getOverride(pkg, manualOverride) {
});
})
.then(function(override) {
// 0.16 Package Config Override Upgrade Path:
// shim becomes meta
var packageConfig = override.systemjs || override;
if (packageConfig.shim) {
packageConfig.meta = packageConfig.meta || {};

for (var s in packageConfig.shim) {
// ignore shim if there is any meta config for this module
if (packageConfig.meta[s + '.js'])
continue;

var curShim = packageConfig.shim[s];
var curMeta = packageConfig.meta[s + '.js'] = {};

if (curShim instanceof Array) {
curMeta.deps = curShim;
}
else if (typeof curShim == 'object') {
if (curShim.deps)
curMeta.deps = curShim.deps;
else if (curShim.imports)
curMeta.deps = curShim.imports;

if (curShim.exports)
curMeta.exports = curShim.exports;
}

curShim.format = 'global';
}
delete packageConfig.shim;
}

upgradePackageConfig(packageConfig);
return override;
});
}

function upgradePackageConfig(packageConfig) {
// 0.16 Package Config Override Upgrade Path:
// shim becomes meta
if (packageConfig.shim) {
packageConfig.meta = packageConfig.meta || {};

for (var s in packageConfig.shim) {
// ignore shim if there is any meta config for this module
if (packageConfig.meta[s + '.js'])
continue;

var curShim = packageConfig.shim[s];
var curMeta = packageConfig.meta[s + '.js'] = {};

if (curShim instanceof Array) {
curMeta.deps = curShim;
}
else if (typeof curShim == 'object') {
if (curShim.deps)
curMeta.deps = curShim.deps;
else if (curShim.imports)
curMeta.deps = curShim.imports;

if (curShim.exports)
curMeta.exports = curShim.exports;
}

curShim.format = 'global';
}
delete packageConfig.shim;
}
}

var injecting = {};
exports.inject = function(pkg, depLoad) {
if (injecting[pkg.exactName]) {
Expand Down Expand Up @@ -762,6 +765,9 @@ function processPackage(pkg, dir, packageConfig) {
})

.then(function(packageConfig) {

upgradePackageConfig(packageConfig);

// directories.lib/dist becomes baseDir
if (!packageConfig.baseDir && packageConfig.directories && (packageConfig.directories.dist || packageConfig.directories.lib))
packageConfig.baseDir = packageConfig.directories.dist || packageConfig.directories.lib;
Expand Down

0 comments on commit 9e3dde7

Please sign in to comment.