From 36904959996d2b5a32b737af43635fffad91181c Mon Sep 17 00:00:00 2001
From: Owen Flood <owenhflood@gmail.com>
Date: Mon, 10 Jul 2017 16:43:17 -0700
Subject: [PATCH] Don't prompt to install serve if already installed (#2761)

* dont prompt if serve is already installed

* change name for readability

* Pin the version
---
 packages/react-dev-utils/package.json                |  1 +
 packages/react-dev-utils/printHostingInstructions.js | 12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json
index b4539788d..e09e990d0 100644
--- a/packages/react-dev-utils/package.json
+++ b/packages/react-dev-utils/package.json
@@ -41,6 +41,7 @@
     "detect-port-alt": "1.1.3",
     "escape-string-regexp": "1.0.5",
     "filesize": "3.3.0",
+    "global-modules": "1.0.0",
     "gzip-size": "3.0.0",
     "html-entities": "1.2.1",
     "inquirer": "3.1.1",
diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js
index f9882d44a..2ef25767a 100644
--- a/packages/react-dev-utils/printHostingInstructions.js
+++ b/packages/react-dev-utils/printHostingInstructions.js
@@ -11,6 +11,8 @@
 
 const chalk = require('chalk');
 const url = require('url');
+const globalModules = require('global-modules');
+const fs = require('fs');
 
 function printHostingInstructions(
   appPackage,
@@ -121,10 +123,12 @@ function printHostingInstructions(
     );
     console.log('You may serve it with a static server:');
     console.log();
-    if (useYarn) {
-      console.log(`  ${chalk.cyan('yarn')} global add serve`);
-    } else {
-      console.log(`  ${chalk.cyan('npm')} install -g serve`);
+    if (!fs.existsSync(`${globalModules}/serve`)) {
+      if (useYarn) {
+        console.log(`  ${chalk.cyan('yarn')} global add serve`);
+      } else {
+        console.log(`  ${chalk.cyan('npm')} install -g serve`);
+      }
     }
     console.log(`  ${chalk.cyan('serve')} -s ${buildFolder}`);
     console.log();
-- 
GitLab