Comparing version 0.3.0 to 1.0.0
{ | ||
"name": "hylite", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "A command line tool for highlighting code", | ||
@@ -5,0 +5,0 @@ "author": "Peter @peterbe Bengtsson", |
@@ -6,1 +6,21 @@ await Bun.build({ | ||
}); | ||
await retroFix(); | ||
async function retroFix() { | ||
// Got this from | ||
// https://github.com/oven-sh/bun/issues/5707#issuecomment-1730511178 | ||
const IMPORT_META_REQUIRE_POLYFILL = `import { createRequire as createImportMetaRequire } from "module"; import.meta.require ||= (id) => createImportMetaRequire(import.meta.url)(id);`; | ||
const DIST_FILE = "./dist/index.js"; | ||
const outputFile = Bun.file(DIST_FILE); | ||
const output = await outputFile.text(); | ||
const newLines: string[] = []; | ||
for (const line of output.split("\n")) { | ||
newLines.push(line); | ||
if (line.startsWith("#!")) { | ||
newLines.push(IMPORT_META_REQUIRE_POLYFILL); | ||
} | ||
} | ||
const newOutput = newLines.join("\n"); | ||
await Bun.write(DIST_FILE, newOutput); | ||
} |
#!/usr/bin/env bun | ||
import fs from "fs"; | ||
import { readFile, writeFile } from "fs/promises"; | ||
import { readdir } from "fs/promises"; | ||
@@ -39,3 +41,3 @@ import { extname } from "path"; | ||
} | ||
code = await Bun.file(args[0]).text(); | ||
code = fs.readFileSync(args[0], "utf8"); | ||
} else { | ||
@@ -47,5 +49,4 @@ code = args[0]; | ||
} else { | ||
for await (const line of console) { | ||
code += line + "\n"; | ||
} | ||
const stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0 | ||
code = stdinBuffer.toString(); | ||
} | ||
@@ -118,4 +119,6 @@ | ||
if (css && !code && !previewServer) { | ||
const cssFile = Bun.file(`node_modules/highlight.js/styles/${css}.css`); | ||
cssContent = await cssFile.text(); | ||
cssContent = await readFile( | ||
`node_modules/highlight.js/styles/${css}.css`, | ||
"utf-8", | ||
); | ||
process.stdout.write(cssContent); | ||
@@ -146,3 +149,3 @@ return; | ||
if (outputFile) { | ||
await Bun.write(outputFile, html); | ||
await writeFile(outputFile, html, "utf-8"); | ||
} else { | ||
@@ -152,3 +155,3 @@ process.stdout.write(html); | ||
} else if (outputFile) { | ||
await Bun.write(outputFile, output); | ||
await writeFile(outputFile, output, "utf-8"); | ||
} else { | ||
@@ -164,4 +167,3 @@ if (wrapped) { | ||
async function getCSS(name = "default") { | ||
const cssFile = Bun.file(`node_modules/highlight.js/styles/${name}.css`); | ||
return await cssFile.text(); | ||
return readFile(`node_modules/highlight.js/styles/${name}.css`, "utf-8"); | ||
} | ||
@@ -168,0 +170,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1755438
13
50877
1