This commit is contained in:
Chris Wanstrath 2025-09-16 20:24:44 -07:00
parent 5fff0e77b8
commit ffd4e6e4a1
2 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import { prettyJSON } from "hono/pretty-json"
import color from "kleur" import color from "kleur"
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config" import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
import { transpile, isFile } from "./utils" import { transpile, isFile, tilde } from "./utils"
import { apps, serveApp } from "./webapp" import { apps, serveApp } from "./webapp"
import { Layout } from "./components/layout" import { Layout } from "./components/layout"
@ -102,9 +102,9 @@ if (process.env.BUN_HOT) {
// //
console.log(color.cyan(NOSE_ICON)) console.log(color.cyan(NOSE_ICON))
console.log(color.blue("NOSE_DIR:"), color.yellow(NOSE_DIR.replace(`/Users/${process.env.USER}/`, "~/"))) console.log(color.blue("NOSE_DIR:"), color.yellow(tilde(NOSE_DIR)))
console.log(color.blue("NOSE_BIN:"), color.yellow(NOSE_BIN.replace(`/Users/${process.env.USER}/`, "~/"))) console.log(color.blue("NOSE_BIN:"), color.yellow(tilde(NOSE_BIN)))
console.log(color.blue("NOSE_WWW:"), color.yellow(NOSE_WWW.replace(`/Users/${process.env.USER}/`, "~/"))) console.log(color.blue("NOSE_WWW:"), color.yellow(tilde(NOSE_WWW)))
export default { export default {
port: process.env.PORT || 3000, port: process.env.PORT || 3000,

View File

@ -23,6 +23,11 @@ export function isDir(path: string): boolean {
} }
} }
// Convert /Users/$USER or /home/$USER to ~ for simplicity
export function tilde(path: string): string {
return path.replace(new RegExp(`/(Users|home)/${process.env.USER}`), "~")
}
// Generate a random 8 character string // Generate a random 8 character string
export function randomID(): string { export function randomID(): string {
return Math.random().toString(36).slice(2, 10) return Math.random().toString(36).slice(2, 10)