Skip to content

Commit 12be9ae

Browse files
move checking for argument into wrapper
1 parent b2cab46 commit 12be9ae

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

bin/create-webextension

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
#!/usr/bin/env node
2+
const chalk = require("chalk");
3+
4+
const USAGE_MSG = `Usage: create-webextension project_dir_name`;
5+
6+
if (!process.argv[2]) {
7+
console.error(`${chalk.red("Missing project dir name.")}\n`);
8+
console.log(USAGE_MSG);
9+
process.exit(1);
10+
}
211

312
require("..").main(process.argv[2]);

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const chalk = require("chalk");
55
const fs = require("mz/fs");
66
const stripAnsi = require("strip-ansi");
77

8-
const USAGE_MSG = `Usage: create-webextension project_dir_name`;
9-
108
const README = `
119
This project contains a blank WebExtension addon, a "white canvas" for your new experiment of
1210
extending and remixing the Web.
@@ -89,9 +87,7 @@ function getProjectManifest(projectDirName) {
8987

9088
exports.main = function main(dirPath) {
9189
if (!dirPath) {
92-
console.error(`${chalk.red("Missing project dir name.")}\n`);
93-
console.log(USAGE_MSG);
94-
process.exit(1);
90+
throw new Error("Project directory name is a compulsory argument");
9591
}
9692

9793
const projectPath = path.resolve(dirPath);

0 commit comments

Comments
 (0)