mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 13:15:49 +08:00
Fix ejecting from a scoped fork (#1727)
* Read script names from own bin instead of guessing This fixes ejecting from a fork that uses a different bin script name. * Fix ejecting for a scoped react-scripts fork We shouldn't hardcode react-scripts because fork name might differ. We also shouldn't rely on it being an immediate child because scoped packages are a level deeper. * Clarify that own* properties only exist before ejecting
This commit is contained in:
19
packages/react-scripts/scripts/eject.js
vendored
19
packages/react-scripts/scripts/eject.js
vendored
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user