diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 9b473ab3d95..b0460036635 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -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 {