Namespace: File

File

Functions to read, write, and manipulate files

Methods

(static) appendFile(filePath, data, encodingopt)

Append data to a file

Parameters:
Name Type Attributes Default Description
filePath String
data Any
encoding String <optional>
null
Since:
  • 0.1.0

(static) appendTextFile(filePath, data, encodingopt)

Append text to a text file

Parameters:
Name Type Attributes Default Description
filePath String
data Any
encoding String <optional>
"utf8"
Since:
  • 0.1.0

(static) dirname()

Get the current directory name for a script

Since:
  • 0.1.0

(static) filename()

Get the current file name for a script

Since:
  • 0.1.0

(static) fileWithPath()

Returns the filename with complete path for the current script

Since:
  • 0.1.0

(static) joinPath(…args)

Joins multiple elements together to create a path

Parameters:
Name Type Attributes Description
args any <repeatable>
Since:
  • 0.1.0

(static) readFile(filePath, encodingopt) → {String|Buffer}

Read the contents of a file

Parameters:
Name Type Attributes Default Description
filePath String
encoding String <optional>
null
Since:
  • 0.1.0
Returns:
Type
String | Buffer

(static) readJSONFile(filePath) → {Object}

Reads a file, parses it as JSON, and returns it

Parameters:
Name Type Description
filePath String
Since:
  • 0.1.0
Returns:
Type
Object

(static) readLines(filePath, encodingopt) → {Array.<String>}

Splits a text file on line endings and returns an array of the lines

Parameters:
Name Type Attributes Default Description
filePath String
encoding String <optional>
"utf8"
Since:
  • 0.1.0
Returns:
Type
Array.<String>

(static) readTextFile(filePath, encodingopt) → {String}

Reads and returns the contents of a text file

Parameters:
Name Type Attributes Default Description
filePath String
encoding String <optional>
"utf8"
Since:
  • 0.1.0
Returns:
Type
String

(static) writeFile(filePath, data, encodingopt)

Writes data to a file

Parameters:
Name Type Attributes Default Description
filePath String
data Any
encoding String <optional>
null
Since:
  • 0.1.0

(static) writeJSONFile(filePath, data)

Writes data to a file as JSON

Parameters:
Name Type Description
filePath String
data Any
Since:
  • 0.1.0

(static) writeLines(filePath, data, encodingopt)

Joins an array of lines and writes them to a file

Parameters:
Name Type Attributes Default Description
filePath String
data Any
encoding String <optional>
"utf8"
Since:
  • 0.1.0

(static) writeTextFile(filePath, data, encodingopt)

Writes data to a file as text

Parameters:
Name Type Attributes Default Description
filePath String
data Any
encoding String <optional>
"utf8"
Since:
  • 0.1.0