readFile (function)
Read the contents of a file from disk.
With no options specified, it reads the file as UTF-8 and returns a string:
But, if you pass { binary: true } as the second argument, it returns an
ArrayBuffer containing the raw bytes from the file:
// ArrayBuffer {
// │0x00000000│ 23 20 79 61 76 61 73 63 72 69 70 74 0A 0A 59 61
// │0x00000010│ 76 61 53 63 72 69 70 74 20 69 73 20 61 20 63 72
// │0x00000020│ 6F 73 73 2D 70 6C 61 74 66 6F 72 6D 20 62 61 73
// │0x00000030│ 68 2D 6C 69 6B 65 20 73 63 72 69 70 74 20 72 75
// ...
readFile(...) (call signature)
Read the contents of a file from disk, as a UTF-8 string.
Example
readFile(...) (call signature)
Read the contents of a file from disk, as a UTF-8 string.
Example
readFile(...) (call signature)
Read the contents of a file from disk, as a UTF-8 string.
Example
binary: false;
}): string;
readFile(...) (call signature)
Read the contents of a file from disk, as an ArrayBuffer.
Example
binary: true;
}): ArrayBuffer;
writeFile (function)
Write the contents of a string or ArrayBuffer to a file.
Strings are written using the UTF-8 encoding.
Example
isFile (function)
Function which returns true if the path points to a regular file.
Example
isDir (function)
Function which returns true if the path points to a directory, or if the path points to a symlink which points to a directory. Otherwise, it returns false.
Example
isLink (function)
Returns true if the path points to a symlink.
Example
isExecutable (function)
Returns true if the resource at the provided path can be executed by the current user.
If nothing exists at that path, an error will be thrown.
Example
}
isReadable (function)
Returns true if the resource at the provided path can be read by the current user.
If nothing exists at that path, an error will be thrown.
Example
}
isWritable (function)
Returns true if a resource at the provided path could be written to by the current user.
Example
}
remove (function)
Delete the file or directory at the specified path.
If the directory isn't empty, its contents will be deleted, too.
Provides the same functionality as the command rm -r.
Example
exists (function)
Returns true if a file or directory exists at the specified path.
Provides the same functionality as the command test -e.
Example
copy (function)
Copies a file or folder from one location to another. Folders are copied recursively.
Provides the same functionality as the command cp -R.
Example
): void;
CopyOptions (type)
Options for copy.
Example
};
};
CopyOptions.whenTargetExists (property)
What to do when attempting to copy something into a location where something else already exists.
Defaults to "error".
Example
CopyOptions.logging (object property)
Options which control logging.
Example
CopyOptions.logging.trace (function property)
If provided, this function will be called multiple times as copy
traverses the filesystem, to help you understand what's going on and/or
troubleshoot things. In most cases, it makes sense to use a logging
function here, like so:
Defaults to the current value of logger.trace. logger.trace
defaults to a no-op function.
CopyOptions.logging.info (function property)
An optional, user-provided logging function to be used for informational messages.
Defaults to the current value of logger.info. logger.info
defaults to a function which writes to stderr.
Example
rename (function)
Rename the file or directory at the specified path.
Provides the same functionality as the command mv.
Example