Skip to content

Commit

Permalink
Read script names from own bin instead of guessing
Browse files Browse the repository at this point in the history
This fixes ejecting from a fork that uses a different bin script name.
  • Loading branch information
gaearon committed Mar 5, 2017
1 parent 991714f commit 55fccd8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ prompt(
console.log(cyan('Updating the scripts'));
delete appPackage.scripts['eject'];
Object.keys(appPackage.scripts).forEach(function (key) {
appPackage.scripts[key] = appPackage.scripts[key]
.replace(/react-scripts (\w+)/g, 'node scripts/$1.js');
console.log(
' Replacing ' +
cyan('"react-scripts ' + key + '"') +
' with ' +
cyan('"node scripts/' + key + '.js"')
);
Object.keys(ownPackage.bin).forEach(function (binKey) {
var regex = new RegExp(binKey + ' (\\w+)', 'g');
appPackage.scripts[key] = appPackage.scripts[key]
.replace(regex, 'node scripts/$1.js');
console.log(
' Replacing ' +
cyan('"' + binKey + ' ' + key + '"') +
' with ' +
cyan('"node scripts/' + key + '.js"')
);
});
});

console.log();
Expand Down

0 comments on commit 55fccd8

Please sign in to comment.