Skip to content

Commit 6511028

Browse files
authored
Merge pull request #155 from jamesgeorge007/feat/validate-installation
chore: validate git installation upfront
2 parents ccfc136 + e0bcd14 commit 6511028

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.bin/create-rust-webpack.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
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 isPresent(dep) {
10+
try {
11+
execSync(dep, {stdio: 'ignore'});
12+
return true;
13+
} catch (err) {
14+
return false;
15+
}
16+
}
17+
918
function run(cmd, args, opts) {
1019
const output = spawnSync(cmd, args, opts);
1120

@@ -18,6 +27,11 @@ function run(cmd, args, opts) {
1827
}
1928
}
2029

30+
if (!isPresent("git --version")) {
31+
console.log('\n git is required');
32+
process.exit(1);
33+
}
34+
2135
let folderName = '.';
2236

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

0 commit comments

Comments
 (0)