Skip to content

Commit

Permalink
Stick to CommonJS as entry-points for executables
Browse files Browse the repository at this point in the history
This is considerably less complicated than the hacky workaround required
to run `bin/html-tty` with Node's ESM flag. Not to mention it eliminates
risk of breakage in future releases.
  • Loading branch information
Alhadis committed Oct 6, 2018
1 parent a089676 commit 7b9a268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
9 changes: 4 additions & 5 deletions bin/html-tty
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
"use strict";

require("../lib/adapters/esm.js")(() => new Promise(resolve => {
new Promise(resolve => {
const fs = require("fs");
if(process.argv[2])
resolve(fs.readFileSync(process.argv[2], "utf8"));
Expand All @@ -13,9 +13,8 @@ require("../lib/adapters/esm.js")(() => new Promise(resolve => {
null !== chunk ? input += chunk : resolve(input);
});
}
}).then(async data => {
const TTYRenderer = (await import("../lib/postproc/tty/renderer.mjs")).default;
const htmlTTY = new TTYRenderer();
}).then(data => {
const htmlTTY = new (require("..").TTYRenderer)();
const isRaw = /\x08/.test(data);
let output = htmlTTY.process(data, isRaw);
if(process.stdout.isTTY)
Expand All @@ -38,4 +37,4 @@ require("../lib/adapters/esm.js")(() => new Promise(resolve => {
}).catch(error => {
console.error(error);
process.exit(1);
}));
});
38 changes: 0 additions & 38 deletions lib/adapters/esm.js

This file was deleted.

0 comments on commit 7b9a268

Please sign in to comment.