mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
allow mounting files directly (#2931)
* allow mounting files directly * fixes from testing * more fixes
This commit is contained in:
@@ -329,6 +329,36 @@ export class FileHelper<A> {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a File Helper for a text file
|
||||
*/
|
||||
static string(path: string): FileHelper<string>
|
||||
static string<A extends string>(
|
||||
path: string,
|
||||
shape: Validator<string, A>,
|
||||
): FileHelper<A>
|
||||
static string<A extends Transformed, Transformed = string>(
|
||||
path: string,
|
||||
shape: Validator<Transformed, A>,
|
||||
transformers: Transformers<string, Transformed>,
|
||||
): FileHelper<A>
|
||||
static string<A extends Transformed, Transformed = string>(
|
||||
path: string,
|
||||
shape?: Validator<Transformed, A>,
|
||||
transformers?: Transformers<string, Transformed>,
|
||||
) {
|
||||
return FileHelper.rawTransformed<A, string, Transformed>(
|
||||
path,
|
||||
(inData) => inData,
|
||||
(inString) => inString,
|
||||
(data) =>
|
||||
(shape || (matches.string as Validator<Transformed, A>)).unsafeCast(
|
||||
data,
|
||||
),
|
||||
transformers,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a File Helper for a .json file.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user