Skip to content

Commit

Permalink
Use installing package manager in README (#7687)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashr81 authored and mrmckeb committed Oct 2, 2019
1 parent 7e2b6b1 commit 6b8fa00
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/react-scripts/scripts/init.js
Expand Up @@ -135,6 +135,24 @@ module.exports = function(
return;
}

// modifies README.md commands based on user used package manager.
if (useYarn) {
try {
const readme = fs.readFileSync(path.join(appPath, 'README.md'), 'utf8');
fs.writeFileSync(
path.join(appPath, 'README.md'),
readme
.replace(/npm start/g, 'yarn start')
.replace(/npm test/g, 'yarn test')
.replace(/npm run build/g, 'yarn build')
.replace(/npm run eject/g, 'yarn eject'),
'utf8'
);
} catch (err) {
// Silencing the error. As it fall backs to using default npm commands.
}
}

// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
// See: https://github.com/npm/npm/issues/1862
try {
Expand Down

0 comments on commit 6b8fa00

Please sign in to comment.