Skip to content

Commit 419e9c5

Browse files
validate git installation upfront
closes #154
1 parent ccfc136 commit 419e9c5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.bin/create-rust-webpack.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env node
22

3-
const { spawnSync } = require("child_process");
3+
const { execSync, spawnSync } = require("child_process");
44
const fs = require("fs");
55
const path = require("path");
66
const cpr = require("cpr");
77
const rimraf = require("rimraf");
88

9+
function validateInstallation(dep) {
10+
let installationStatus;
11+
try {
12+
execSync(dep, {stdio: 'ignore'});
13+
installationStatus = true;
14+
} catch (err) {
15+
installationStatus = false;
16+
}
17+
return installationStatus;
18+
}
19+
920
function run(cmd, args, opts) {
1021
const output = spawnSync(cmd, args, opts);
1122

@@ -18,6 +29,11 @@ function run(cmd, args, opts) {
1829
}
1930
}
2031

32+
if (!validateInstallation("git help -g")) {
33+
console.log('\n git is required to be installed!');
34+
process.exit(1);
35+
}
36+
2137
let folderName = '.';
2238

2339
if (process.argv.length >= 3) {

0 commit comments

Comments
 (0)