diff --git a/.bin/create-rust-webpack.js b/.bin/create-rust-webpack.js index 629d269..d23cf9d 100755 --- a/.bin/create-rust-webpack.js +++ b/.bin/create-rust-webpack.js @@ -1,11 +1,20 @@ #!/usr/bin/env node -const { spawnSync } = require("child_process"); +const { execSync, spawnSync } = require("child_process"); const fs = require("fs"); const path = require("path"); const cpr = require("cpr"); const rimraf = require("rimraf"); +function isPresent(dep) { + try { + execSync(dep, {stdio: 'ignore'}); + return true; + } catch (err) { + return false; + } +} + function run(cmd, args, opts) { const output = spawnSync(cmd, args, opts); @@ -18,6 +27,11 @@ function run(cmd, args, opts) { } } +if (!isPresent("git --version")) { + console.log('\n git is required'); + process.exit(1); +} + let folderName = '.'; if (process.argv.length >= 3) {