-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moves minimum node version to v18 (latest LTS at time of PR) - Changes gauge-js to an ES module, removing all use of CommonJS requires - Prefers use of node: prefixed imports - Upgrades and de-duplicates dependencies to latest ---- Signed-off-by: Chad Wilson <[email protected]> Signed-off-by: Zabil Cheriya Maliackal <[email protected]> Co-authored-by: Zabil Cheriya Maliackal <[email protected]>
- Loading branch information
1 parent
a315148
commit 2237e9f
Showing
50 changed files
with
979 additions
and
730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
/** | ||
* Use `module.exports` to export an object which can be used with a `require()` on this file. | ||
*/ | ||
const vowelList = ["a", "e", "i", "o", "u"]; | ||
|
||
var vowelList = ["a", "e", "i", "o", "u"]; | ||
|
||
var numVowels = function (word) { | ||
var vowelArr = word.split("").filter(function (elem) { return vowelList.indexOf(elem) > -1; }); | ||
const numVowels = function (word) { | ||
const vowelArr = word.split("").filter(function (elem) { | ||
return vowelList.indexOf(elem) > -1; | ||
}); | ||
return vowelArr.length; | ||
}; | ||
|
||
module.exports = { | ||
export default { | ||
vowelList: vowelList, | ||
numVowels: numVowels | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,75 @@ | ||
#! /usr/bin/env node | ||
|
||
var version = process.versions.node.split("."); | ||
if (parseInt(version[0]) < 16) { | ||
throw new Error("gauge-js requires Node.js version 16+. Current version: " + process.versions.node); | ||
const minNodeVersion = 18; | ||
const version = process.versions.node.split("."); | ||
if (Number.parseInt(version[0]) < minNodeVersion) { | ||
throw new Error( | ||
`gauge-js requires Node.js version ${minNodeVersion}+. Current version: ${process.versions.node}`, | ||
); | ||
} | ||
|
||
var fs = require("fs"), | ||
path = require("path"), | ||
child_process = require("child_process"); | ||
import child_process from "node:child_process"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
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") { | ||
const skeldir = path.join(__dirname, "skel"); | ||
const srcdir = path.join(process.env.GAUGE_PROJECT_ROOT, "tests"); | ||
const envdir = path.join(process.env.GAUGE_PROJECT_ROOT, "env", "default"); | ||
const testCode = "step_implementation.js"; | ||
const jsPropertyFile = "js.properties"; | ||
|
||
if (process.argv[2] === "--init") { | ||
console.log("Initialising Gauge JavaScript project"); | ||
fs.mkdir(srcdir, 484, function (err) { | ||
fs.mkdir(srcdir, 484, (err) => { | ||
if (err && err.code !== "EEXIST") { | ||
console.error(err); | ||
} else { | ||
fs.createReadStream(path.join(skeldir, testCode)) | ||
.pipe(fs.createWriteStream(path.join(srcdir, testCode))); | ||
fs.createReadStream(path.join(skeldir, testCode)).pipe( | ||
fs.createWriteStream(path.join(srcdir, testCode)), | ||
); | ||
} | ||
}); | ||
|
||
fs.mkdir(path.dirname(envdir), 484, function (err) { | ||
fs.mkdir(path.dirname(envdir), 484, (err) => { | ||
if (err && err.code !== "EEXIST") { | ||
console.error(err); | ||
} else { | ||
fs.mkdir(envdir, 484, function (err) { | ||
fs.mkdir(envdir, 484, (err) => { | ||
if (err && err.code !== "EEXIST") { | ||
console.error(err); | ||
} else { | ||
fs.createReadStream(path.join(skeldir, jsPropertyFile)) | ||
.pipe(fs.createWriteStream(path.join(envdir, jsPropertyFile))); | ||
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"]; | ||
} else if (process.argv[2] === "--start") { | ||
let 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" }); | ||
const cmd = process.env.gauge_nodejs_bin || "node"; | ||
const runner = child_process.spawn(cmd, args, { | ||
env: process.env, | ||
silent: false, | ||
stdio: "inherit", | ||
}); | ||
process.on("beforeExit", (code) => { | ||
try { | ||
if (!runner.killed) { runner.kill("SIGINT"); } | ||
if (!runner.killed) { | ||
runner.kill("SIGINT"); | ||
} | ||
} finally { | ||
process.exit(code); | ||
} | ||
}); | ||
runner.on("error", function (err) { | ||
runner.on("error", (err) => { | ||
console.trace(err.stack); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.