Skip to content

Commit 5eb7c73

Browse files
OwenFloodJohnNilsson
authored andcommitted
Don't prompt to install serve if already installed (#2761)
* dont prompt if serve is already installed * change name for readability * Pin the version
1 parent 772a447 commit 5eb7c73

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/react-dev-utils/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"detect-port-alt": "1.1.3",
4242
"escape-string-regexp": "1.0.5",
4343
"filesize": "3.3.0",
44+
"global-modules": "1.0.0",
4445
"gzip-size": "3.0.0",
4546
"html-entities": "1.2.1",
4647
"inquirer": "3.1.1",

packages/react-dev-utils/printHostingInstructions.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
const chalk = require('chalk');
1313
const url = require('url');
14+
const globalModules = require('global-modules');
15+
const fs = require('fs');
1416

1517
function printHostingInstructions(
1618
appPackage,
@@ -121,10 +123,12 @@ function printHostingInstructions(
121123
);
122124
console.log('You may serve it with a static server:');
123125
console.log();
124-
if (useYarn) {
125-
console.log(` ${chalk.cyan('yarn')} global add serve`);
126-
} else {
127-
console.log(` ${chalk.cyan('npm')} install -g serve`);
126+
if (!fs.existsSync(`${globalModules}/serve`)) {
127+
if (useYarn) {
128+
console.log(` ${chalk.cyan('yarn')} global add serve`);
129+
} else {
130+
console.log(` ${chalk.cyan('npm')} install -g serve`);
131+
}
128132
}
129133
console.log(` ${chalk.cyan('serve')} -s ${buildFolder}`);
130134
console.log();

0 commit comments

Comments
 (0)