fix: hardcoded '/' in normalized options.fs, fixes #412, #408

Changes including:
- will not call fs.resolve when normalizing `fs`
- removed hardcoded `/`
- mandatory `fs.dirname` for relative reference
- mandatory `fs.sep`, defaults to '/'
This commit is contained in:
Harttle
2021-10-16 12:10:55 +08:00
committed by harttle
parent df6d62fd59
commit 9cfa43b8ae
17 changed files with 124 additions and 54 deletions
+4 -2
View File
@@ -1,8 +1,10 @@
import { AssertionError } from './error'
export function assert <T> (predicate: T | null | undefined, message?: () => string) {
export function assert <T> (predicate: T | null | undefined, message?: string | (() => string)) {
if (!predicate) {
const msg = message ? message() : `expect ${predicate} to be true`
const msg = typeof message === 'function'
? message()
: (message || `expect ${predicate} to be true`)
throw new AssertionError(msg)
}
}
+4
View File
@@ -11,6 +11,10 @@ export function isFunction (value: any): value is Function {
return typeof value === 'function'
}
export function escapeRegex (str: string) {
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
}
export function promisify<T1, T2> (fn: (arg1: T1, cb: (err: Error | null, result: T2) => void) => void): (arg1: T1) => Promise<T2>;
export function promisify<T1, T2, T3> (fn: (arg1: T1, arg2: T2, cb: (err: Error | null, result: T3) => void) => void): (arg1: T1, arg2: T2) => Promise<T3>;
export function promisify (fn: any) {