-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (31 loc) · 980 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
const commander = require("commander");
const packageJson = require("./package.json");
commander
.version(packageJson.version, "-v, --version")
.usage("[options] <url ...>")
.option(
"-o, --output [value]",
"Where to output the generated files - defaults to the current working directory (optional)."
)
.option(
"-t, --template [value]",
"Where is sketch file which is used as template. It allows relative path from current working directory or default template (yellow).",
"yellow"
)
.parse(process.argv);
if (commander.args.length < 1) {
console.log("url not given.");
}
for (const url of commander.args) {
const result = /^https?\:\/\/(www\.)?hackforplay\.xyz\/works\/(\w+)/.exec(
url
);
const workId = result && result[2];
if (!result || typeof workId !== "string") {
console.error(`Invalid URL: ${url}`);
continue;
}
const generate = require("./generate");
generate(workId, commander);
}