An open API service indexing awesome lists of open source software.

https://github.com/valtech-commerce/fs

graceful-fs / fs-extra wrapper
https://github.com/valtech-commerce/fs

fs npm-package promise sync

Last synced: about 2 months ago
JSON representation

graceful-fs / fs-extra wrapper

Awesome Lists containing this project

README

          

# fs wrappers
[![npm][npm-badge]][npm-url]
[![npms.io: Score][npmsio-badge]][npmsio-url]
[![libraries.io: SourceRank][librariesio-badge]][librariesio-url]
[![Tests][tests-badge]][tests-url]
[![License: MIT][license-badge]][license-url]

> graceful-fs / fs-extra wrapper with goodies

## Install

```sh
$ npm install @valtech-commerce/fs
```

## Usage

```js
import { fsAsync, fsSync } from "@valtech-commerce/fs";

fsSync.move("/path1/path2/path3", "/path4");

fsAsync.chmodPattern("/path1/path2/**/*.js", 0o775).then(() => {
console.log("Yeah!");
});
```

## Async - API

> `fs` is [graceful-fs](https://github.com/isaacs/node-graceful-fs)

> `fse` is [fs-extra](https://github.com/jprichardson/node-fs-extra)


### access
Maps [`fs.promises.access`](https://nodejs.org/api/fs.html#fs_fspromises_access_path_mode)


### appendFile
Maps [`fs.promises.appendFile`](https://nodejs.org/api/fs.html#fs_fspromises_appendfile_path_data_options)


### chmod
Maps [`fs.promises.chmod`](https://nodejs.org/api/fs.html#fs_fspromises_chmod_path_mode)


### chmodPattern(pattern, mode *[, options]*)
Applies [`fs.chmod`](https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback) for matching [`glob`](https://www.npmjs.com/package/glob) pattern file/dir.

#### pattern
*Required*

Type: `String`

glob pattern.

#### mode
*Required*

Type: `Number`

File mode.

#### options
Type: `Object`

glob [options](https://www.npmjs.com/package/glob#options).


### chown
Maps [`fs.promises.chown`](https://nodejs.org/api/fs.html#fs_fspromises_chown_path_uid_gid)


### compressFile(source *[, destination]*)
Compresses file using gzip
`Promise` returns destination

#### source
*Required*

Type: `String`

Path of file to compress.

#### destination
Type: `String`

Default: Same as source with a `.gz` added at the end

Path of file when compressed.


### copy
Maps [`fse.copy`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy.md)


### copyFile
Maps [`fs.promises.copyFile`](https://nodejs.org/api/fs.html#fs_fspromises_copyfile_src_dest_flags)


### decompressFile(source *[, destination]*)
Decompresses file using gzip
`Promise` returns destination

#### source
*Required*

Type: `String`

Path of file to decompress.

#### destination
Type: `String`

Default: Same as source with the `.gz` removed at the end

Path of file when decompressed.


### emptyDir
Maps [`fse.emptyDir`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/emptyDir.md)


### ensureDir
Maps [`fse.ensureDir`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md)


### ensureFile
Maps [`fse.ensureFile`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureFile.md)


### ensureLink
Maps [`fse.ensureLink`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureLink.md)


### ensureSymlink
Maps [`fse.ensureSymlink`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureSymlink.md)


### lchmod
Maps [`fs.promises.lchmod`](https://nodejs.org/api/fs.html#fs_fspromises_lchmod_path_mode)


### lchown
Maps [`fs.promises.lchown`](https://nodejs.org/api/fs.html#fs_fspromises_lchown_path_uid_gid)


### link
Maps [`fs.promises.link`](https://nodejs.org/api/fs.html#fs_fspromises_link_existingpath_newpath)


### lstat
Maps [`fs.promises.lstat`](https://nodejs.org/api/fs.html#fs_fspromises_lstat_path_options)


### mergeFiles(sources, destination)
Merge multiple files into a single file

#### sources
*Required*

Type: `Array` of `String`

Path of files to merge.

#### destination
*Required*

Type: `String`

Path of merged file. (If it ends with `.gz` it will be compressed using gzip)


### mkdir
Maps [`fs.promises.mkdir`](https://nodejs.org/api/fs.html#fs_fspromises_mkdir_path_mode)


### mkdirp
Maps [`fse.mkdirp`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md)


### mkdirs
Maps [`fse.mkdirs`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md)


### mkdtemp
Maps [`fs.promises.mkdtemp`](https://nodejs.org/api/fs.html#fs_fspromises_mkdtemp_prefix_options)


### move
Maps [`fse.move`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/move.md)


### open
Maps [`fs.promises.open`](https://nodejs.org/api/fs.html#fs_fspromises_open_path_flags_mode)


### outputCompressed(file, content)
Almost the same as writeCompressed, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write.

#### content
*Required*

Type: `String`

Content to write.


### outputFile
Maps [`fse.outputFile`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputFile.md)


### outputJson(file, object *[, options]*)
Almost the same as writeJson, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON.stringify [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).

#### options.space
Type: `String` or `Number`

JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).


### outputJson5(file, object *[, options]*)
Almost the same as writeJson5, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON5.stringify [replacer](https://json5.org#json5stringify).

#### options.space
Type: `String` or `Number`

JSON5.stringify [replacer](https://json5.org#json5stringify).


### outputXml(file, object *[, options]*)
Almost the same as writeXml, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options
Type: `Object`

xml2js.Builder().buildObject [options](https://github.com/Leonidas-from-XIV/node-xml2js#options-for-the-builder-class).


### outputYaml(file, object)
Almost the same as writeYaml, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.


### pathExists
Maps [`fse.pathExists`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/pathExists.md)


### readCompressed(file)
Reads and decompresses file using gzip.
`Promise` returns an `String`

#### file
*Required*

Type: `String`

Path of file to read.


### readdir
Maps [`fs.promises.readdir`](https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options)


### readFile
Maps [`fs.promises.readFile`](https://nodejs.org/api/fs.html#fs_fspromises_readfile_path_options)


### readJson(file *[, reviver]*)
Reads a JSON file and then parses it into an object.

`Promise` returns an `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### reviver
Type: `Function`

JSON.parse [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Syntax).


### readJson5(file *[, reviver]*)
Reads a JSON5 file and then parses it into an object.

`Promise` returns an `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### reviver
Type: `Function`

JSON5.parse [reviver](https://json5.org#json5parse).


### readlink
Maps [`fs.promises.readlink`](https://nodejs.org/api/fs.html#fs_fspromises_readlink_path_options)


### readXml(file *[, options]*)
Reads a XML file and then parses it into an object.

`Promise` returns an `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### options
Type: `Object`

xml2js.parseString [options](https://github.com/Leonidas-from-XIV/node-xml2js#options).


### readYaml(file)
Reads a YAML file and then parses it into an object.

`Promise` returns an `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)


### realpath
Maps [`fs.promises.realpath`](https://nodejs.org/api/fs.html#fs_fspromises_realpath_path_options)


### remove
Maps [`fse.remove`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/remove.md)


### removeEmptyDir(root)
Uses [delete-empty](https://github.com/jonschlinkert/delete-empty) to recursively delete all empty folders in a directory and child directories

`Promise` returns an `Array` of deleted directories

#### root
*Required*

Type: `String`

Path of root directory to scan


### removePattern(pattern)
Uses [rimraf](https://github.com/isaacs/rimraf) to delete files and directories via a globbing pattern

#### pattern
*Required*

Type: `String`

Globbing pattern


### rename
Maps [`fs.promises.rename`](https://nodejs.org/api/fs.html#fs_fspromises_rename_oldpath_newpath)


### rmdir
Maps [`fs.promises.rmdir`](https://nodejs.org/api/fs.html#fs_fspromises_rmdir_path)


### scandir(root, type, [options])
Uses [klaw](https://github.com/jprichardson/node-klaw) to scan directory for files or directories.

Return `Array` of files / directories

#### root
*Required*

Type: `String`

Path of directory to scan.

#### type
*Required*

Type: `String`

Scan for `file` or `dir`

#### options.recursive
Type: `Boolean`

Scan in subdirectories

*Default: false*

#### options.fullPath
Type: `String`

Return full absolute path instead of relative path from scanned directory

*Default: false*

#### options.pattern
Type: `String`

Filter results with [minimatch](https://github.com/isaacs/minimatch) pattern

*Default: '\*\*'*

#### options.keepJunk
Type: `Boolean`

Keep [junk](https://github.com/sindresorhus/junk) files (also filters out `.gitkeep`)

*Default: false*


### stat
Maps [`fs.promises.stat`](https://nodejs.org/api/fs.html#fs_fspromises_stat_path_options)


### symlink
Maps [`fs.promises.symlink`](https://nodejs.org/api/fs.html#fs_fspromises_symlink_target_path_type)


### truncate
Maps [`fs.promises.truncate`](https://nodejs.org/api/fs.html#fs_fspromises_truncate_path_len)


### unlink
Maps [`fs.promises.unlink`](https://nodejs.org/api/fs.html#fs_fspromises_unlink_path)


### utimes
Maps [`fs.promises.utimes`](https://nodejs.org/api/fs.html#fs_fspromises_utimes_path_atime_mtime)


### writeCompressed(file, content)
Compresses and writes content to file using gzip.

#### file
*Required*

Type: `String`

Path of file to write.

#### content
*Required*

Type: `String`

Content to write.


### writeFile
Maps [`fs.promises.writeFile`](https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options)


### writeJson(file, content *[, options]*)
Writes an object to a JSON file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON.stringify [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).

#### options.space
Type: `String` or `Number`

JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).


### writeJson5(file, content *[, options]*)
Writes an object to a JSON5 file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON5.stringify [replacer](https://json5.org#json5stringify).

#### options.space
Type: `String` or `Number`

JSON5.stringify [replacer](https://json5.org#json5stringify).


### writeXml(file, content *[, options]*)
Writes an object to a XML file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options
Type: `Object`

xml2js.Builder().buildObject [options](https://github.com/Leonidas-from-XIV/node-xml2js#options-for-the-builder-class).


### writeYaml(file, object)
Writes an object to a YAML file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.


## Sync - API

> `fs` is [graceful-fs](https://github.com/isaacs/node-graceful-fs)

> `fse` is [fs-extra](https://github.com/jprichardson/node-fs-extra)


### access
Maps [`fs.accessSync`](https://nodejs.org/api/fs.html#fs_fs_accesssync_path_mode)


### appendFile
Maps [`fs.appendFileSync`](https://nodejs.org/api/fs.html#fs_fs_appendfilesync_path_data_options)


### chmod
Maps [`fs.chmodSync`](https://nodejs.org/api/fs.html#fs_fs_chmodsync_path_mode)


### chown
Maps [`fs.chownSync`](https://nodejs.org/api/fs.html#fs_fs_chownsync_path_uid_gid)


### close
Maps [`fs.closeSync`](https://nodejs.org/api/fs.html#fs_fs_closesync_fd)


### compressFile(source *[, destination]*)
Compresses file using gzip
Return `String` destination

#### source
*Required*

Type: `String`

Path of file to compress.

#### destination
Type: `String`

Default: Same as source with a `.gz` added at the end

Path of file when compressed.


### copy
Maps [`fse.copySync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy-sync.md)


### copyFile
Maps [`fs.copyFileSync`](https://nodejs.org/api/fs.html#fs_fs_copyfilesync_src_dest_flags)


### decompressFile(source *[, destination]*)
Decompresses file using gzip
Return `String` destination

#### source
*Required*

Type: `String`

Path of file to decompress.

#### destination
Type: `String`

Default: Same as source with the `.gz` removed at the end

Path of file when decompressed.


### emptyDir
Maps [`fse.emptyDirSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/emptyDir-sync.md)


### ensureDir
Maps [`fse.ensureDirSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir-sync.md)


### ensureFile
Maps [`fse.ensureFileSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureFile-sync.md)


### ensureLink
Maps [`fse.ensureLinkSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureLink-sync.md)


### ensureSymlink
Maps [`fse.ensureSymlinkSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureSymlink-sync.md)


### exists
Maps [`fs.existsSync`](https://nodejs.org/api/fs.html#fs_fs_existssync_path)


### existsCase(path)
Almost the same as `fss.exists`, except that it also validates the case-sensitivity of the path.


### fchmod
Maps [`fs.fchmodSync`](https://nodejs.org/api/fs.html#fs_fs_fchmodsync_fd_mode)


### fchown
Maps [`fs.fchownSync`](https://nodejs.org/api/fs.html#fs_fs_fchownsync_fd_uid_gid)


### fdatasync
Maps [`fs.fdatasyncSync`](https://nodejs.org/api/fs.html#fs_fs_fdatasyncsync_fd)


### fstat
Maps [`fs.fstatSync`](https://nodejs.org/api/fs.html#fs_fs_fstatsync_fd_options)


### fsync
Maps [`fs.fsyncSync`](https://nodejs.org/api/fs.html#fs_fs_fsyncsync_fd)


### ftruncate
Maps [`fs.ftruncateSync`](https://nodejs.org/api/fs.html#fs_fs_ftruncatesync_fd_len)


### futimes
Maps [`fs.futimesSync`](https://nodejs.org/api/fs.html#fs_fs_futimessync_fd_atime_mtime)


### lchmod
Maps [`fs.lchmodSync`](https://nodejs.org/api/fs.html#fs_fs_lchmodsync_path_mode)


### lchown
Maps [`fs.lchownSync`](https://nodejs.org/api/fs.html#fs_fs_lchownsync_path_uid_gid)


### link
Maps [`fs.linkSync`](https://nodejs.org/api/fs.html#fs_fs_linksync_existingpath_newpath)


### lstat
Maps [`fs.lstatSync`](https://nodejs.org/api/fs.html#fs_fs_lstatsync_path_options)


### mkdir
Maps [`fs.mkdirSync`](https://nodejs.org/api/fs.html#fs_fs_mkdirsync_path_mode)


### mkdirp
Maps [`fse.mkdirpSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir-sync.md)


### mkdirs
Maps [`fse.mkdirsSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir-sync.md)


### mkdtemp
Maps [`fs.mkdtempSync`](https://nodejs.org/api/fs.html#fs_fs_mkdtempsync_prefix_options)


### move
Maps [`fse.moveSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/move-sync.md)


### open
Maps [`fs.openSync`](https://nodejs.org/api/fs.html#fs_fs_opensync_path_flags_mode)


### outputCompressed(file, content)
Almost the same as writeCompressed, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write.

#### content
*Required*

Type: `String`

Content to write.


### outputFile
Maps [`fse.outputFileSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputFile-sync.md)


### outputJson(file, object *[, options]*)
Almost the same as writeJson, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON.stringify [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).

#### options.space
Type: `String` or `Number`

JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).


### outputJson5(file, object *[, options]*)
Almost the same as writeJson5, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON5.stringify [replacer](https://json5.org#json5stringify).

#### options.space
Type: `String` or `Number`

JSON5.stringify [space](https://json5.org#json5stringify).


### outputXml(file, object *[, options]*)
Almost the same as writeXml, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options
Type: `Object`

xml2js.Builder().buildObject [options](https://github.com/Leonidas-from-XIV/node-xml2js#options-for-the-builder-class).


### outputYaml(file, object)
Almost the same as writeYaml, except that if the directory does not exist, it's created.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.


### pathExists
Maps [`fse.pathExistsSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/pathExists-sync.md)


### read
Maps [`fs.readSync`](https://nodejs.org/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position)


### readCompressed(file)
Reads and decompresses file using gzip.

Return `String`

#### file
*Required*

Type: `String`

Path of file to read.


### readdir
Maps [`fs.readdirSync`](https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options)


### readFile
Maps [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options)


### readJson(file *[, reviver]*)
Reads a JSON file and then parses it into an object.

Return `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### reviver
Type: `Function`

JSON.parse [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Syntax).


### readJson5(file *[, reviver]*)
Reads a JSON5 file and then parses it into an object.

Return `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### reviver
Type: `Function`

JSON5.parse [reviver](https://json5.org#json5parse).


### readlink
Maps [`fs.readlinkSync`](https://nodejs.org/api/fs.html#fs_fs_readlinksync_path_options)


### readXml(file *[, options]*)
Reads a XML file and then parses it into an object.

Return `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)

#### options
Type: `Object`

xml2jsParser.parseStringSync [options](https://github.com/vavere/xml2js-parser#options).


### readYaml(file)
Reads a YAML file and then parses it into an object.

Return `Object`

#### file
*Required*

Type: `String`

Path of file to read. (If it ends with `.gz` it will be decompressed using gzip)


### realpath
Maps [`fs.realpathSync`](https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options)


### realpath.native
Maps [`fs.realpathSync.native`](https://nodejs.org/api/fs.html#fs_fs_realpathsync_native_path_options)


### remove
Maps [`fse.removeSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/remove-sync.md)


### removeEmptyDir(root)
Uses [delete-empty](https://github.com/jonschlinkert/delete-empty) to recursively delete all empty folders in a directory and child directories

Return `Array` of deleted directories

#### root
*Required*

Type: `String`

Path of root directory to scan


### removePattern(pattern)
Uses [rimraf](https://github.com/isaacs/rimraf) to delete files and directories via a globbing pattern

#### pattern
*Required*

Type: `String`

Globbing pattern


### rename
Maps [`fs.renameSync`](https://nodejs.org/api/fs.html#fs_fs_renamesync_oldpath_newpath)


### rmdir
Maps [`fs.rmdirSync`](https://nodejs.org/api/fs.html#fs_fs_rmdirsync_path)


### scandir(root, type, [options])
Uses [klaw-sync](https://github.com/manidlou/node-klaw-sync) to scan directory for files or directories.

Return `Array` of files / directories

#### root
*Required*

Type: `String`

Path of directory to scan.

#### type
*Required*

Type: `String`

Scan for `file` or `dir`

#### options.recursive
Type: `Boolean`

Scan in subdirectories

*Default: false*

#### options.fullPath
Type: `String`

Return full absolute path instead of relative path from scanned directory

*Default: false*

#### options.pattern
Type: `String`

Filter results with [minimatch](https://github.com/isaacs/minimatch) pattern

*Default: '\*\*'*

#### options.keepJunk
Type: `Boolean`

Keep [junk](https://github.com/sindresorhus/junk) files (also filters out `.gitkeep`)

*Default: false*


### stat
Maps [`fs.statSync`](https://nodejs.org/api/fs.html#fs_fs_statsync_path_options)


### symlink
Maps [`fs.symlinkSync`](https://nodejs.org/api/fs.html#fs_fs_symlinksync_target_path_type)


### truncate
Maps [`fs.truncateSync`](https://nodejs.org/api/fs.html#fs_fs_truncatesync_path_len)


### unlink
Maps [`fs.unlinkSync`](https://nodejs.org/api/fs.html#fs_fs_unlinksync_path)


### utimes
Maps [`fs.utimesSync`](https://nodejs.org/api/fs.html#fs_fs_utimessync_path_atime_mtime)


### write
Maps [`fs.writeSync`](https://nodejs.org/api/fs.html#fs_fs_writesync_fd_buffer_offset_length_position)


### writeCompressed(file, content)
Compresses and writes content to file using gzip.

#### file
*Required*

Type: `String`

Path of file to write.

#### content
*Required*

Type: `String`

Content to write.


### writeFile
Maps [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)


### writeJson(file, content *[, options]*)
Writes an object to a JSON file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON.stringify [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).

#### options.space
Type: `String` or `Number`

JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax).


### writeJson5(file, content *[, options]*)
Writes an object to a JSON5 file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options.replacer
Type: `Function`

JSON5.stringify [replacer](https://json5.org#json5stringify).

#### options.space
Type: `String` or `Number`

JSON5.stringify [space](https://json5.org#json5stringify).


### writeXml(file, content *[, options]*)
Writes an object to a XML file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.

#### options
Type: `Object`

xml2js.Builder().buildObject [options](https://github.com/Leonidas-from-XIV/node-xml2js#options-for-the-builder-class).


### writeYaml(file, object)
Writes an object to a YAML file.

#### file
*Required*

Type: `String`

Path of file to write. (If it ends with `.gz` it will be compressed using gzip)

#### object
*Required*

Type: `Object`

Object to write.


## License

[MIT](LICENSE) © [Valtech Canada inc.](https://www.valtech.ca/)

[npm-badge]: https://img.shields.io/npm/v/@valtech-commerce/fs?style=flat-square
[npmsio-badge]: https://img.shields.io/npms-io/final-score/@valtech-commerce/fs?style=flat-square
[librariesio-badge]: https://img.shields.io/librariesio/sourcerank/npm/@valtech-commerce/fs?style=flat-square
[tests-badge]: https://img.shields.io/github/actions/workflow/status/valtech-commerce/fs/tests.yaml?style=flat-square&branch=main
[license-badge]: https://img.shields.io/badge/license-MIT-green?style=flat-square
[npm-url]: https://www.npmjs.com/package/@valtech-commerce/fs
[npmsio-url]: https://npms.io/search?q=%40valtech-commerce%2Ffs
[librariesio-url]: https://libraries.io/npm/@valtech-commerce%2Ffs
[tests-url]: https://github.com/valtech-commerce/fs/actions/workflows/tests.yaml?query=branch%3Amain
[license-url]: https://opensource.org/licenses/MIT