File system module for Hexo.
npm install hexo-fs


File system module for [Hexo].
- Support for both Promise and callback interface.
- Use [graceful-fs] to avoid EMFILE error and various improvements.
- Use [chokidar] for consistent file watching.
`` bash`
$ npm install hexo-fs --save
` js`
const fs = require('hexo-fs');
> Some methods in the original fs module are not listed below, but they're available in hexo-fs.
Test whether or not the given path exists by checking with the file system.
Synchronous version of fs.exists.
Creates a directory and its parent directories if they does not exist.
Synchronous version of fs.mkdirs.
Writes data to a file.
Option | Description | Default
--- | --- | ---
encoding | File encoding | utf8mode | Mode | 438 (0666 in octal)flag | Flag | w
Synchronous version of fs.writeFile.
Appends data to a file.
Option | Description | Default
--- | --- | ---
encoding | File encoding | utf8mode | Mode | 438 (0666 in octal)flag | Flag | w
Synchronous version of fs.appendFile.
Copies a file from src to dest.
Copies a directory from src to dest. It returns an array of copied files.
Option | Description | Default
--- | --- | ---
ignoreHidden | Ignore hidden files | trueignorePattern | Ignore files which pass the regular expression |
Lists files in a directory.
Option | Description | Default
--- | --- | ---
ignoreHidden | Ignore hidden files | trueignorePattern | Ignore files which pass the regular expression |
Synchronous version of fs.listDir.
Reads the entire contents of a file.
Option | Description | Default
--- | --- | ---
encoding | File encoding | utf8flag | Flag | rescape | Escape UTF BOM and line ending in the content | true
Synchronous version of fs.readFile.
Deletes all files in a directory. It returns an array of deleted files.
Option | Description | Default
--- | --- | ---
ignoreHidden | Ignore hidden files | trueignorePattern | Ignore files which pass the regular expression |exclude | Ignore files in the array |
Synchronous version of fs.emptyDir.
Removes a directory and all files in it.
Synchronous version of fs.rmdir.
Watches changes of a file or a directory.
See Chokidar API for more info.
Ensures the given path is available to use or appends a number to the path.
Synchronous version of fs.ensurePath.
Creates the parent directories if they does not exist and returns a writable stream.
Synchronous version of fs.ensureWriteStream`.
MIT
[graceful-fs]: https://github.com/isaacs/node-graceful-fs
[Hexo]: https://hexo.io/
[chokidar]: https://github.com/paulmillr/chokidar