Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "hylite", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A command line tool for highlighting code", | ||
@@ -17,10 +17,15 @@ "author": "Peter @peterbe Bengtsson", | ||
"scripts": { | ||
"test": "echo 'not done yet'", | ||
"css": "bun run src/index.ts -c", | ||
"list-css": "bun run src/index.ts --list-css", | ||
"install:husky": "husky install", | ||
"test": "bun test", | ||
"lint": "prettier --check \"src/**/*.ts\"", | ||
"prettier": "prettier --write \"src/**/*.ts\"", | ||
"build": "bun run src/build.ts", | ||
"release": "np", | ||
"prerelease": "bun build ./src/index.ts --outdir=dist --outfile=index.js" | ||
"prerelease": "bun run build" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "latest", | ||
"husky": "^8.0.3", | ||
"np": "^8.0.4", | ||
@@ -27,0 +32,0 @@ "prettier": "^3.0.3" |
@@ -19,2 +19,3 @@ #!/usr/bin/env bun | ||
.option("--list-css", "List possible names for CSS files and exit") | ||
.option("--version", "Prints the current version") | ||
.argument("[string]", "string to highlight"); | ||
@@ -42,3 +43,3 @@ | ||
} | ||
} else if (options.listCss) { | ||
} else if (options.listCss || options.version || options.css) { | ||
// pass | ||
@@ -72,2 +73,3 @@ } else { | ||
listCss: options.listCss, | ||
version: options.version, | ||
}); | ||
@@ -84,2 +86,3 @@ | ||
listCss = false, | ||
version = false, | ||
}: { | ||
@@ -92,4 +95,10 @@ htmlWrap?: boolean; | ||
listCss?: boolean; | ||
version?: boolean; | ||
} = {}, | ||
) { | ||
if (version) { | ||
const packageJson = require("../package.json"); | ||
process.stdout.write(`${packageJson.version}\n`); | ||
return; | ||
} | ||
if (listCss) { | ||
@@ -178,3 +187,3 @@ const cssNames = await getCSSNames(); | ||
if (url.pathname === "/") { | ||
let choicesHtml = "<ul class=choices>"; | ||
let choicesHtml = '<ul class="choices">'; | ||
for (const name of cssNames) { | ||
@@ -188,3 +197,14 @@ choicesHtml += `<li><a href="?css=${name}">${name}</a></li>`; | ||
const css = await getCSS(loadedCssName); | ||
let css = ""; | ||
try { | ||
css = await getCSS(loadedCssName); | ||
} catch (error) { | ||
if ( | ||
error instanceof Error && | ||
"code" in error && | ||
error.code === "ENOENT" | ||
) { | ||
return new Response("css file not found", { status: 400 }); | ||
} | ||
} | ||
@@ -191,0 +211,0 @@ const headStyle = getHeadStyle(loadedCssName); |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1753114
12
50831
1
4