Skip to content

Commit 359032b

Browse files
committedSep 14, 2019
feat: adds --source parameter to CLI
1 parent 2207666 commit 359032b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎bin/compileCLI.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ const cliOptions = [
77
{ name: "module", alias: "m", type: Boolean },
88
{ name: "output", alias: "o", type: String },
99
{ name: "input", alias: "i", type: String },
10-
{ name: "spawn", type: Boolean}
10+
{ name: "spawn", type: Boolean },
11+
{ name: "source", type: String }
1112
];
1213
const args = cliParser(cliOptions);
1314
if (!("standalone" in args)) args.standalone = false;
1415
if (!("module" in args)) args.module = false;
1516
if (!("output" in args)) args.output = null;
1617
if (!("input" in args)) args.input = null;
1718
if (!("spawn" in args)) args.spawn = false;
19+
if (!("source" in args)) args.source = null;
1820
function inputSource(input, callback) {
1921
fs.readFile(input, function (error, buffer) {
2022
if (error) throw error;
@@ -51,6 +53,8 @@ function compile(source) {
5153
if (args.input !== null) {
5254
if (args.output !== null) console.log("Opening " + args.input + " for compilation.");
5355
inputSource(args.input, compile);
56+
} else if(args.source) {
57+
compile(args.source);
5458
} else {
5559
stdInSource(compile);
5660
}

0 commit comments

Comments
 (0)