From 4d7b7544e74db1aaca22e847b233ed1f3b95b72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Fri, 30 Dec 2016 07:59:28 -0800 Subject: [PATCH] Use npm script hooks to avoid && in deploy script (#1324) --- packages/react-scripts/scripts/build.js | 3 ++- packages/react-scripts/template/README.md | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 4b568caae54..42be50d43a8 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -181,7 +181,8 @@ function build(previousSizeMap) { console.log(' ' + chalk.dim('// ...')); console.log(' ' + chalk.yellow('"scripts"') + ': {'); console.log(' ' + chalk.dim('// ...')); - console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"npm run build&&gh-pages -d build"')); + console.log(' ' + chalk.yellow('"predeploy"') + ': ' + chalk.yellow('"npm run build",')); + console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"gh-pages -d build"')); console.log(' }'); console.log(); console.log('Then run:'); diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 047fdfbe0b1..e55e6c9f4f8 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1132,17 +1132,18 @@ To publish it at [https://myusername.github.io/my-app](https://myusername.github npm install --save-dev gh-pages ``` -Add the following script in your `package.json`: +Add the following scripts in your `package.json`: ```js // ... "scripts": { // ... - "deploy": "npm run build&&gh-pages -d build" + "predeploy": "npm run build", + "deploy": "gh-pages -d build" } ``` -(Note: the lack of whitespace is intentional.) +The `predeploy` script will run automatically before `deploy` is run. #### Step 3: Deploy the site by running `npm run deploy`