Skip to content

Commit 55fccd8

Browse files
committed
Read script names from own bin instead of guessing
This fixes ejecting from a fork that uses a different bin script name.
1 parent 991714f commit 55fccd8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/react-scripts/scripts/eject.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,17 @@ prompt(
120120
console.log(cyan('Updating the scripts'));
121121
delete appPackage.scripts['eject'];
122122
Object.keys(appPackage.scripts).forEach(function (key) {
123-
appPackage.scripts[key] = appPackage.scripts[key]
124-
.replace(/react-scripts (\w+)/g, 'node scripts/$1.js');
125-
console.log(
126-
' Replacing ' +
127-
cyan('"react-scripts ' + key + '"') +
128-
' with ' +
129-
cyan('"node scripts/' + key + '.js"')
130-
);
123+
Object.keys(ownPackage.bin).forEach(function (binKey) {
124+
var regex = new RegExp(binKey + ' (\\w+)', 'g');
125+
appPackage.scripts[key] = appPackage.scripts[key]
126+
.replace(regex, 'node scripts/$1.js');
127+
console.log(
128+
' Replacing ' +
129+
cyan('"' + binKey + ' ' + key + '"') +
130+
' with ' +
131+
cyan('"node scripts/' + key + '.js"')
132+
);
133+
});
131134
});
132135

133136
console.log();

0 commit comments

Comments
 (0)