1f61eb5ca9
deploy-www / deploy (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / sign-cli-macos (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
typecheck / typecheck (push) Has been cancelled
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
export function getFilename(path: string | undefined) {
|
|
if (!path) return ""
|
|
const trimmed = path.replace(/[/\\]+$/, "")
|
|
const parts = trimmed.split(/[/\\]/)
|
|
return parts[parts.length - 1] ?? ""
|
|
}
|
|
|
|
export function getDirectory(path: string | undefined) {
|
|
if (!path) return ""
|
|
const trimmed = path.replace(/[/\\]+$/, "")
|
|
const parts = trimmed.split(/[/\\]/)
|
|
return parts.slice(0, parts.length - 1).join("/") + "/"
|
|
}
|
|
|
|
export function getFilenameTruncated(path: string | undefined, maxLength = 20) {
|
|
const filename = getFilename(path)
|
|
if (filename.length <= maxLength) return filename
|
|
const lastDot = filename.lastIndexOf(".")
|
|
const extension = lastDot <= 0 ? "" : filename.slice(lastDot)
|
|
const available = maxLength - extension.length - 1
|
|
if (available <= 0) return filename.slice(0, maxLength - 1) + "…"
|
|
return filename.slice(0, available) + "…" + extension
|
|
}
|
|
|
|
export function truncateMiddle(text: string, maxLength = 20) {
|
|
if (text.length <= maxLength) return text
|
|
const available = maxLength - 1
|
|
const start = Math.ceil(available / 2)
|
|
const end = Math.floor(available / 2)
|
|
return text.slice(0, start) + "…" + text.slice(-end)
|
|
}
|