Skip to main content

FileUtils

@webda/utils


Variable: FileUtils

const FileUtils: StorageFinder & object

Defined in: packages/utils/src/serializers.ts:228

Allow save/load of yaml or json file

Type Declaration​

clean​

clean: (...files) => void

Parameters​

files​

...string[]

Returns​

void

getConfigurationFile​

getConfigurationFile: (filename) => string

Parameters​

filename​

string

Returns​

string

load​

load: (filename, format?) => any

Parameters​

filename​

string

format?​

Format

Returns​

any

loadConfigurationFile​

loadConfigurationFile: (filename, allowImports?) => any

Parameters​

filename​

string

allowImports?​

boolean

Returns​

any

save​

save: (object, filename, format?) => void

Save a YAML or JSON file based on its extension

You can compress files too if you add a .gz extension

Parameters​

object​

any

to serialize

filename​

string

to save

format?​

Format

Returns​

void

Example​

FileUtils.save({ hello: "world" }, "test.json");
FileUtils.save({ hello: "world" }, "test.yaml");
FileUtils.save({ hello: "world" }, "test.json.gz");
FileUtils.save({ hello: "world" }, "test.yaml.gz");

walkSync​

walkSync: (path, processor, options?, depth?) => void

Parameters​

path​

string

processor​

(filepath) => void

options?​

WalkerOptionsType

depth?​

number

Returns​

void