Skip to content

Commit 6b8fa00

Browse files
ashr81mrmckeb
authored andcommitted
Use installing package manager in README (#7687)
1 parent 7e2b6b1 commit 6b8fa00

File tree

1 file changed

+18
-0
lines changed
  • packages/react-scripts/scripts

1 file changed

+18
-0
lines changed

packages/react-scripts/scripts/init.js

+18
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ module.exports = function(
135135
return;
136136
}
137137

138+
// modifies README.md commands based on user used package manager.
139+
if (useYarn) {
140+
try {
141+
const readme = fs.readFileSync(path.join(appPath, 'README.md'), 'utf8');
142+
fs.writeFileSync(
143+
path.join(appPath, 'README.md'),
144+
readme
145+
.replace(/npm start/g, 'yarn start')
146+
.replace(/npm test/g, 'yarn test')
147+
.replace(/npm run build/g, 'yarn build')
148+
.replace(/npm run eject/g, 'yarn eject'),
149+
'utf8'
150+
);
151+
} catch (err) {
152+
// Silencing the error. As it fall backs to using default npm commands.
153+
}
154+
}
155+
138156
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
139157
// See: https://github.com/npm/npm/issues/1862
140158
try {

0 commit comments

Comments
 (0)