node's fs with more helpers
npm install fs-plusYet another filesystem helper based on node's fs
module. This library exports everything from node's fs module but with some
extra helpers.
``sh`
npm install fs-plus
`coffee`
fs = require 'fs-plus'
- String relativePath: The string representing the relative path. If the
path is prefixed with '~', it will be expanded to the current user's home
directory.
- String: The absolute path or the relative path if it's unable to
determine its real path.
segment as referring to the
home directory. This method does not query the filesystem.#### Params
- String
pathToNormalize: The string containing the abnormal path. If the
path is prefixed with '~', it will be expanded to the current user's home
directory.#### Return
- String Returns a normalized path.
$3
Convert an absolute path to tilde path on Linux and macOS:
/Users/username/dev => ~/dev#### Params
- String
pathToTildify: The string containing the full path.#### Return
- String Returns a tildified path.
$3
Get path to store application specific data.#### Return
- String Returns the absolute path or null if platform isn't supported
- macOS:
~/Library/Application Support/
- Windows: %AppData%
- Linux: /var/lib$3
Is the given path absolute?#### Params
- String
pathToCheck: The relative or absolute path to check.#### Return
- Bolean Returns
true if the path is absolute, false otherwise.$3
Returns true if a file or folder at the specified path exists.$3
Returns true if the given path exists and is a directory.$3
Asynchronously checks that the given path exists and is a directory.$3
Returns true if the specified path exists and is a file.$3
Returns true if the specified path is a symbolic link.$3
Calls back with true if the specified path is a symbolic link.$3
Returns true if the specified path is executable.$3
Returns the size of the specified path.$3
Returns an Array with the paths of the files and directories
contained within the directory path. It is not recursive.Params
- String rootPath: The absolute path to the directory to list.
- Array extensions: An array of extensions to filter the results by. If none are
given, none are filtered (optional).$3
Asynchronously lists the files and directories in the given path. The listing is not recursive.$3
Get all paths under the given path.#### Params
- String
rootPath The {String} path to start at.#### Return
- Array Returns an array of strings under the given path.
$3
Moves the file or directory to the target synchronously.$3
Removes the file or directory at the given path synchronously.$3
Open, write, flush, and close a file, writing the given content synchronously.
It also creates the necessary parent directories.$3
Open, write, flush, and close a file, writing the given content
asynchronously.
It also creates the necessary parent directories.$3
Copies the given path recursively and synchronously.$3
Create a directory at the specified path including any missing
parent directories synchronously.$3
Create a directory at the specified path including any missing
parent directories asynchronously.$3
Recursively walk the given path and execute the given functions
synchronously.#### Params
- String
rootPath: The string containing the directory to recurse into.
- Function onFile: The function to execute on each file, receives a single argument
the absolute path.
- Function onDirectory: The function to execute on each directory, receives a single
argument the absolute path (defaults to onFile). If this
function returns a falsy value then the directory is not
entered.$3
Public: Recursively walk the given path and execute the given functions
asynchronously.$3
Hashes the contents of the given file.#### Params
- String
pathToDigest: The string containing the absolute path.#### Return
- String Returns a string containing the MD5 hexadecimal hash.
$3
Finds a relative path among the given array of paths.#### Params
- Array
loadPaths: An array of absolute and relative paths to search.
- String pathToResolve The string containing the path to resolve.
- Array extensions An array of extensions to pass to {resolveExtensions} in
which case pathToResolve should not contain an extension
(optional).#### Return
Returns the absolute path of the file to be resolved if it's found and
undefined otherwise.
$3
Like .resolve but uses node's modules paths as the load paths to
search.$3
Finds the first file in the given path which matches the extension
in the order given.#### Params
- String
pathToResolve: the string containing relative or absolute path of the
file in question without the extension or '.'.
- Array extensions: the ordered array of extensions to try.#### Return
Returns the absolute path of the file if it exists with any of the given
extensions, otherwise it's undefined.
$3
Returns true for extensions associated with compressed files.$3
Returns true for extensions associated with image files.$3
Returns true for extensions associated with pdf files.$3
Returns true for extensions associated with binary files.$3
Returns true for files named similarily to 'README'$3
Returns true for extensions associated with Markdown files.$3
Is the filesystem case insensitive?
Returns true if case insensitive, false otherwise.$3
Is the filesystem case sensitive?
Returns true if case sensitive, false otherwise.$3
Calls fs.statSync, catching all exceptions raised. This method calls fs.statSyncNoException when provided by the underlying fs module (Electron < 3.0).
Returns fs.Stats if the file exists, false otherwise.$3
Calls fs.lstatSync, catching all exceptions raised. This method calls fs.lstatSyncNoException when provided by the underlying fs module (Electron < 3.0).
Returns fs.Stats if the file exists, false` otherwise.