From 0736ae31e3a0b1cc048c198f6dd841ce4173c678 Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 6 Nov 2019 00:40:45 +0530 Subject: [PATCH] chore: handle unknown flags (#157) * fix: tweak closes #156 * fix: prevent crash --- .bin/create-rust-webpack.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.bin/create-rust-webpack.js b/.bin/create-rust-webpack.js index d23cf9d..7cefb83 100755 --- a/.bin/create-rust-webpack.js +++ b/.bin/create-rust-webpack.js @@ -32,10 +32,18 @@ if (!isPresent("git --version")) { process.exit(1); } +const args = process.argv.slice(2); + +if (args.some(arg => arg.includes('-'))) { + console.log(`Error: unknown option ${args.filter(arg => arg.includes('-'))}`); + process.exit(1); +} + let folderName = '.'; -if (process.argv.length >= 3) { - folderName = process.argv[2]; +if (args.length >= 1) { + folderName = args[0]; + if (!fs.existsSync(folderName)) { fs.mkdirSync(folderName); }