Skip to content

Commit

Permalink
chore!: convert tsconfigcheck pkg to es module
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this change is breaking for older versions of Node
that don't support es modules
  • Loading branch information
tmillr committed Aug 18, 2022
1 parent 388b27d commit eff5259
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*
*/

const fs = require("fs");
const JSON5 = require("JSON5");
const traverseSchema = require("json-schema-traverse");
const https = require("node:https");
import { readFileSync } from "node:fs";
import JSON5 from "JSON5";
import traverseSchema from "json-schema-traverse";
import { get as httpsGet } from "node:https";

/**
* @param {URL} url
* @returns {Promise<string>}
* @returns {Promise<string>} the request body
*/
function request(url) {
return new Promise((resolve, reject) => {
Expand All @@ -30,8 +30,7 @@ function request(url) {
handleError(new Error("request timed out"));
}, 30000);

https
.get(url, (res) => {
httpsGet(url, (res) => {
res.on("data", (chunk) => {
body += chunk;
});
Expand Down Expand Up @@ -109,7 +108,7 @@ async function main() {
let tsconfig;
const arg = process.argv[2];

f = (f || fs.readFileSync(arg ? arg : "./tsconfig.json", "utf8")).replace(
f = (f || readFileSync(arg ? arg : "./tsconfig.json", "utf8")).replace(
/^([ \t]*)\/\/[ \t]*("[^\n]+"\s*:)/gm,
"$1$2"
);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"bugs": {
"url": "https://github.com/tmillr/tsconfigcheck/issues"
},
"type": "module",
"main": "index.js",
"bin": "index.js",
"files": [
Expand Down

0 comments on commit eff5259

Please sign in to comment.