Import actions/checkout @v4
Build and Test / build (push) Failing after 14s
Check dist / check-dist (push) Successful in 48s
CodeQL / Analyze (javascript) (push) Failing after 1s
Licensed / Check licenses (push) Successful in 13s
Build and Test / test (ubuntu-latest) (push) Failing after 34s
Build and Test / test-bypass-proxy (push) Failing after 1s
Build and Test / test-git-container (push) Failing after 46s
Build and Test / test-output (push) Failing after 1s
Build and Test / test-proxy (push) Failing after 13m3s
Build and Test / test (macos-latest) (push) Has been cancelled
Build and Test / test (windows-latest) (push) Has been cancelled

This commit is contained in:
fourbroad
2026-06-17 07:48:49 +08:00
commit 039ede8ebe
102 changed files with 54235 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
import * as fs from 'fs'
export function directoryExistsSync(path: string, required?: boolean): boolean {
if (!path) {
throw new Error("Arg 'path' must not be empty")
}
let stats: fs.Stats
try {
stats = fs.statSync(path)
} catch (error) {
if ((error as any)?.code === 'ENOENT') {
if (!required) {
return false
}
throw new Error(`Directory '${path}' does not exist`)
}
throw new Error(
`Encountered an error when checking whether path '${path}' exists: ${
(error as any)?.message ?? error
}`
)
}
if (stats.isDirectory()) {
return true
} else if (!required) {
return false
}
throw new Error(`Directory '${path}' does not exist`)
}
export function existsSync(path: string): boolean {
if (!path) {
throw new Error("Arg 'path' must not be empty")
}
try {
fs.statSync(path)
} catch (error) {
if ((error as any)?.code === 'ENOENT') {
return false
}
throw new Error(
`Encountered an error when checking whether path '${path}' exists: ${
(error as any)?.message ?? error
}`
)
}
return true
}
export function fileExistsSync(path: string): boolean {
if (!path) {
throw new Error("Arg 'path' must not be empty")
}
let stats: fs.Stats
try {
stats = fs.statSync(path)
} catch (error) {
if ((error as any)?.code === 'ENOENT') {
return false
}
throw new Error(
`Encountered an error when checking whether path '${path}' exists: ${
(error as any)?.message ?? error
}`
)
}
if (!stats.isDirectory()) {
return true
}
return false
}