/provider/file

The file provider module exports a method to fetch resources from the local file system.

Methods

(inner) file(ref) → {File|Error}

The file method requires a reference for a file in the local filesystem. A path for the file will be extracted from the reference.

Matched SRC_* variables in the src reference string are replaced with values from the global xyzEnv.

The file is read synchronous from the filesystem.

The buffer returned from the read process will be parsed as json if the referenced filename extension is matched. Otherwise the buffer is returned as string.

The node import module attributes allow access to the directory name through the meta property.

Parameters:
NameTypeDescription
refobject | string

The file reference maybe defined as an object or string. A string is assumed to be the params.url property of the file location.

Returns:

The file will be returned as parsed json or string if the readFileSync process succeeds.

Type: 
File | Error