Skip to content

Commit 3948d55

Browse files
committed
3.2.0 init changes
1 parent be635c7 commit 3948d55

File tree

1 file changed

+29
-11
lines changed
  • packages/react-scripts/scripts

1 file changed

+29
-11
lines changed

packages/react-scripts/scripts/init.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ module.exports = function(
136136
return;
137137
}
138138

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

208-
// wptheme intercept -- stop the standard create-react-app init here... wptheme will take over and display the final message.
209-
return initWpTheme(
210-
appPath,
211-
appName,
212-
verbose,
213-
originalDirectory,
214-
template,
215-
readmeExists,
216-
useTypeScript,
217-
useYarn
218-
);
226+
// wptheme intercept -- stop the standard create-react-app init here... wptheme will take over and display the final message.
227+
return initWpTheme(
228+
appPath,
229+
appName,
230+
verbose,
231+
originalDirectory,
232+
template,
233+
readmeExists,
234+
useTypeScript,
235+
useYarn
236+
);
219237

220238
// Display the most elegant way to cd.
221239
// This needs to handle an undefined originalDirectory for

0 commit comments

Comments
 (0)