Skip to content

Commit 75b721c

Browse files
n3tralexdriaguine
authored andcommitted
Skip gh-page setup instruction if scripts.deploy has been added (facebook#1222)
1 parent 41d4751 commit 75b721c

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: packages/react-scripts/scripts/build.js

+20-16
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ function build(previousSizeMap) {
158158
console.log();
159159

160160
var openCommand = process.platform === 'win32' ? 'start' : 'open';
161-
var homepagePath = require(paths.appPackageJson).homepage;
161+
var appPackage = require(paths.appPackageJson);
162+
var homepagePath = appPackage.homepage;
162163
var publicPath = config.output.publicPath;
163164
if (homepagePath && homepagePath.indexOf('.github.io/') !== -1) {
164165
// "homepage": "http://user.github.io/project"
@@ -167,23 +168,26 @@ function build(previousSizeMap) {
167168
console.log();
168169
console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.');
169170
console.log('To publish it at ' + chalk.green(homepagePath) + ', run:');
170-
console.log();
171-
if (useYarn) {
172-
console.log(' ' + chalk.cyan('yarn') + ' add --dev gh-pages');
173-
} else {
174-
console.log(' ' + chalk.cyan('npm') + ' install --save-dev gh-pages');
171+
// If script deploy has been added to package.json, skip the instructions
172+
if (typeof appPackage.scripts.deploy === 'undefined') {
173+
console.log();
174+
if (useYarn) {
175+
console.log(' ' + chalk.cyan('yarn') + ' add --dev gh-pages');
176+
} else {
177+
console.log(' ' + chalk.cyan('npm') + ' install --save-dev gh-pages');
178+
}
179+
console.log();
180+
console.log('Add the following script in your ' + chalk.cyan('package.json') + '.');
181+
console.log();
182+
console.log(' ' + chalk.dim('// ...'));
183+
console.log(' ' + chalk.yellow('"scripts"') + ': {');
184+
console.log(' ' + chalk.dim('// ...'));
185+
console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"npm run build&&gh-pages -d build"'));
186+
console.log(' }');
187+
console.log();
188+
console.log('Then run:');
175189
}
176190
console.log();
177-
console.log('Add the following script in your ' + chalk.cyan('package.json') + '.');
178-
console.log();
179-
console.log(' ' + chalk.dim('// ...'));
180-
console.log(' ' + chalk.yellow('"scripts"') + ': {');
181-
console.log(' ' + chalk.dim('// ...'));
182-
console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"npm run build&&gh-pages -d build"'));
183-
console.log(' }');
184-
console.log();
185-
console.log('Then run:');
186-
console.log();
187191
console.log(' ' + chalk.cyan(useYarn ? 'yarn' : 'npm') + ' run deploy');
188192
console.log();
189193
} else if (publicPath !== '/') {

0 commit comments

Comments
 (0)