Skip to content

Commit f533e69

Browse files
authored
Merge pull request #1 from Oda2/master
feat: Verifica se o Yarn está instalado
2 parents 2be9030 + 913c009 commit f533e69

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/create-react-dependency/stages/installDependencies.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
const { execSync } = require("child_process");
44

5+
const yarnInstalled = () => {
6+
try {
7+
execSync('yarnpkg --version', { stdio: 'ignore' });
8+
return true;
9+
} catch (error) {
10+
return false;
11+
}
12+
}
13+
514
const installDependencies = dir => {
615
const originalDirectory = process.cwd();
716
try {
817
process.chdir(dir);
918

10-
execSync("yarnpkg install", { stdio: "inherit" });
19+
if (yarnInstalled) {
20+
execSync("yarnpkg install", { stdio: "inherit" });
21+
} else {
22+
execSync("npm install", { stdio: "inherit" });
23+
}
24+
1125
} catch (err) {
1226
console.log(`\x1b[31m${err}\x1b[0m`);
1327
}

0 commit comments

Comments
 (0)