Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use installing package manager in README #7687

Merged
merged 3 commits into from Oct 2, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/react-scripts/scripts/init.js
Expand Up @@ -135,6 +135,21 @@ module.exports = function(
return;
}

// modifies README.md commands based on user used package manager.
if (useYarn) {
try {
const data = fs.readFileSync(path.join(appPath, 'README.md'), 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename data to readme and modify that directly instead of creating another formatted variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iansu I renamed variable to the readme and modifying directly. I used variable naming reference from the same file.

let formatted = data
.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');
fs.writeFileSync(path.join(appPath, 'README.md'), formatted, '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