forked from getgauge/gauge-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·50 lines (43 loc) · 1.59 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env node
var version = process.versions.node.split(".");
if (parseInt(version[0]) === 0 && parseInt(version[1]) < 12) {
throw new Error("gauge-js requires Node.js version 0.12+. Current version: " + process.versions.node);
}
var fs = require("fs"),
path = require("path"),
child_process = require("child_process");
var skeldir = path.join(__dirname, "skel"),
srcdir = path.join(process.env.GAUGE_PROJECT_ROOT, "tests"),
envdir = path.join(process.env.GAUGE_PROJECT_ROOT, "env", "default"),
testCode = "step_implementation.js",
jsPropertyFile = "js.properties";
if(process.argv[2] === "--init") {
console.log("Initialising Gauge JavaScript project");
fs.mkdir(srcdir, 484, function(err) {
if (err && err.code !== "EEXIST") {
console.error(err);
} else {
fs.createReadStream(path.join(skeldir, testCode))
.pipe(fs.createWriteStream(path.join(srcdir, testCode)));
}
});
fs.mkdir(envdir, 484, function(err) {
if (err && err.code !== "EEXIST") {
console.error(err);
} else {
fs.createReadStream(path.join(skeldir, jsPropertyFile))
.pipe(fs.createWriteStream(path.join(envdir, jsPropertyFile)));
}
});
}
else if(process.argv[2] === "--start") {
var args = ["./src/gauge.js", "--run"];
if(process.env.gauge_nodejs_args) {
args = process.env.gauge_nodejs_args.split(" ").concat(args);
}
var cmd = process.env.gauge_nodejs_bin || "node";
var runner = child_process.spawn(cmd, args, { env: process.env, silent: false, stdio: "inherit" });
runner.on("error", function (err) {
console.trace(err.stack);
});
}