Skip to content

Commit d5b166a

Browse files
committed
Global installs dont have a local node_modules, so dont try cache the warning
1 parent ae19b67 commit d5b166a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/create-react-app/createReactApp.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ function writeWarningFile() {
6868
ourPackageInNodeModules,
6969
'given-deprecation-warning'
7070
);
71-
fs.writeFileSync(warningFilePath, 'true');
71+
72+
if (fs.existsSync(ourPackageInNodeModules)) {
73+
fs.writeFileSync(warningFilePath, 'true');
74+
return true;
75+
}
76+
return false;
7277
}
7378

7479
let projectName;
@@ -83,11 +88,14 @@ function init() {
8388
console.log(
8489
chalk.underline('https://react.dev/learn/start-a-new-react-project')
8590
);
86-
console.log('');
87-
console.log(
88-
chalk.grey('This error message will only be shown once per install.')
89-
);
90-
writeWarningFile();
91+
92+
const wroteWarningFile = writeWarningFile();
93+
if (wroteWarningFile) {
94+
console.log('');
95+
console.log(
96+
chalk.grey('This error message will only be shown once per install.')
97+
);
98+
}
9199
}
92100

93101
const program = new commander.Command(packageJson.name)

0 commit comments

Comments
 (0)