Skip to content

Commit

Permalink
[Packager] Alert user when a module is redirected
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Sep 28, 2015
1 parent 7cf7163 commit e6a30da
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,29 @@ class ResolutionRequest {

.then(([oldModuleName, toModuleName]) => {

if (oldModuleName !== toModuleName) {
redirectAlert(oldModuleName, toModuleName);
}

if (toModuleName === null) {
redirectAlert(oldModuleName);
return this._getNullModule(oldModuleName);
}

if (globalConfig.redirect[toModuleName] !== undefined) {
let oldModuleName = toModuleName;
toModuleName = globalConfig.redirect[toModuleName];
if (toModuleName === false) {
redirectAlert(oldModuleName);
return this._getNullModule(oldModuleName);
}
toModuleName = globalConfig.resolve(toModuleName);
redirectAlert(oldModuleName, toModuleName);
}

if (inArray(NODE_PATHS, toModuleName)
&& !this._hasteMap._map[toModuleName]) {
redirectAlert(toModuleName);
return this._getNullModule(toModuleName);
}

Expand Down Expand Up @@ -400,6 +408,19 @@ class ResolutionRequest {
}
}

function redirectAlert(oldName, newName) {
if (newName == null) {
newName = color.gray('null');
} else if (typeof newName === 'boolean') {
newName = color.yellow(newName);
}
log.moat(1);
log.it(color.green.bold('redirect ')
+ oldName
+ color.green(' -> ')
+ newName);
log.moat(1);
}

function UnableToResolveError() {
Error.call(this);
Expand Down

0 comments on commit e6a30da

Please sign in to comment.