Skip to content

Commit

Permalink
patch removed util methods for vows (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhsf authored Mar 19, 2024
1 parent 07c6b13 commit e2151b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"version": "genversion --es6 lib/version.ts && git add lib/version.ts",
"test": "npm run test:ts && npm run test:legacy",
"test:ts": "jest",
"test:legacy": "npm run build -- --declaration false && vows test/*_test.js",
"test:legacy": "npm run build -- --declaration false && ./test/scripts/vows.js test/*_test.js",
"typecheck": "tsc --noEmit",
"cover": "jest --coverage",
"eslint": "eslint --env node --ext .ts .",
Expand Down
15 changes: 15 additions & 0 deletions test/scripts/vows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
/**
* @fileoverview Vows logs using methods from `util` that were removed in node v12. To avoid cryptic
* error messages when tests fail, we patch those methods using `console.log`.
* @see {@link https://nodejs.org/api/deprecations.html#DEP0026|`util.print` deprecation}
* @see {@link https://nodejs.org/api/deprecations.html#DEP0027|`util.puts` deprecation}
* @see {@link https://nodejs.org/docs/latest-v0.10.x/api/util.html|Docs for deprecated `util` methods}
*/

// Patch deprecated util methods
const util = require("node:util");
util.print = (...args) => console.log(args.join(''));
util.puts = (...args) => console.log(args.join('\n'));
// Call vows executable
require("vows/bin/vows");

0 comments on commit e2151b6

Please sign in to comment.