A set of functions & values to work with files and directories. The majority of these functions come straight from fs-jetpack, a fantastic API for working with the file system. All jetpack-based functions have an equivalent *Async version if you need it.

You can access these tools on the @weex-cli/core, via const { fs } = require('@weex-cli/core').

separator

This value is the path separator \ or / depending on the OS.

toolbox.fs.separator // '/' on posix but '\' on windows

eol

This value is the end of line byte sequence.

toolbox.fs.eol // '\n' on posix but '\r\n' on windows

homedir

This function retrieves the path to the home directory.

toolbox.fs.homedir() // '/Users/jh' on my macOS machine

subdirectories

Finds the immediate subdirectories in a given directory.

toolbox.fs.subdirectories(`~/Desktop`) // []

append

Appends data to the end of a file.

chmodSync

Changes directory ownership. See more in the fs documentation.

copy

Copies a file or a directory.

cwd

Gets the current working directory.

dir

Ensures a directory exists and creates a new jetpack instance with it's cwd pointing there.

exists

Checks to see if file or directory exists.

file

Ensures a file exists.

find

Finds files or directories.

inspect

Grabs information about a file or directory.

inspectTree

Grabs nested information about a set of files or directories.

list

Gets a directory listing, like ls.

move

Moves files and directories.

path

Grabs path parts as a string.

read

Reads the contents of a file as a string or JSON.

remove

Deletes a file or directory.

rename

Renames a file or directory.

resolve

Resolves a sequence of paths or path segments into an absolute path.

symlink

Makes a symbolic link to a file or directory.

write

Writes data to a file.