Methods

(inner) fileHash(path, encoding) → {string}

Compute a hash for a file's contents

Parameters:
NameTypeDefaultDescription
pathstring

File path

encodingstringutf8

[utf8] - File encoding

Returns:

The hex encoded hash digest

Type: 
string

(inner) safePath(file, base) → {string|undefined}

Examines if a relative path resolves under the CWD

Parameters:
NameTypeDescription
filestring

The relative file path

basestring

[process.cwd()] - The base path to resolve file path

Returns:

undefined if file path is not considered safe

Type: 
string | undefined
Example
safePath('../../../../../etc/passwd'); // Returns `undefined`

(inner) validateType(name, value, type) → {undefined}

Validate th type of an argument

Parameters:
NameTypeDescription
namestring

The argument's name

valueany

The argument's value

typestring

The expected value type

Throws:

Error if validation fails

Returns:

When validation passes

Type: 
undefined