{"name":"mem-fs-editor","version":"8.0.0-beta.0","description":"File edition helpers working on top of mem-fs","scripts":{"pretest":"eslint .","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/SBoudrias/mem-fs-editor.git"},"author":{"name":"Simon Boudrias"},"license":"MIT","main":"lib/index.js","dependencies":{"commondir":"^1.0.1","deep-extend":"^0.6.0","ejs":"^3.1.5","globby":"^11.0.1","isbinaryfile":"^4.0.0","multimatch":"^5.0.0","normalize-path":"^3.0.0","through2":"^4.0.2","vinyl":"^2.2.1"},"devDependencies":{"coveralls":"^3.0.3","escape-regexp":"0.0.1","eslint":"^6.0.0","eslint-config-xo-space":"^0.21.0","jest":"^24.8.0","mem-fs":"^1.0.0","sinon":"^8.0.0"},"jest":{"collectCoverage":true,"coverageDirectory":"coverage","testEnvironment":"node"},"engines":{"node":">=12.10.0"},"readme":"# mem-fs-editor [![Node.js CI](https://github.com/SBoudrias/mem-fs-editor/workflows/Node.js%20CI/badge.svg)](https://github.com/SBoudrias/mem-fs-editor/actions?query=workflow%3A%22Node.js+CI%22) [![NPM version](https://badge.fury.io/js/mem-fs-editor.svg)](http://badge.fury.io/js/mem-fs-editor) [![Coverage Status](https://coveralls.io/repos/github/SBoudrias/mem-fs-editor/badge.svg)](https://coveralls.io/github/SBoudrias/mem-fs-editor)\n\nFile edition helpers working on top of [mem-fs](https://github.com/SBoudrias/mem-fs)\n\n## Usage\n\n```js\nvar memFs = require(\"mem-fs\");\nvar editor = require(\"mem-fs-editor\");\n\nvar store = memFs.create();\nvar fs = editor.create(store);\n\nfs.write(\"somefile.js\", \"var a = 1;\");\n```\n\n### `#read(filepath, [options])`\n\nRead a file and return its contents as a string.\n\nYou can alternatively get the raw contents buffer if you pass `options.raw = true`.\n\nBy default, calling `read()` on a file path that does not exist throws error. You can, however, pass `options.defaults = 'your default content'` to get a default content you pass in, if you prefer to not deal with try/catch.\n\n### `#readJSON(filepath, [defaults])`\n\nRead a file and parse its contents as JSON.\n\n`readJSON()` internally calls `read()` but will not throw an error if the file path you pass in does not exist. If you pass in an optional `defaults`, the `defaults` content will be returned in case of the target file is missing, instead of `undefined`. (Error would still be thrown if `JSON.parse` failed to parse your target file.)\n\n### `#write(filepath, contents)`\n\nReplace the content of a file (existing or new) with a string or a buffer.\n\n### `#writeJSON(filepath, contents[, replacer [, space]])`\n\nReplace the content of a file (existing or new) with an object that is to be converted by calling `JSON.stringify()`.\n\n`contents` should usually be a JSON object, but it can technically be anything that is acceptable by [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).\n\nOptionally pass `replacer` and `space` as the last two arguments, as defined by [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). `spacer` is used to format the output string (prettify).\n\nDefault value for `space` is `2`, when not specified.\n\n### `#append(filepath, contents, [options])`\n\nAppend the new contents to the current file contents.\n\n- `options.trimEnd` (default `true`). Trim trailing whitespace of the current file contents.\n- `options.separator` (default `os.EOL`). Separator to insert between current and new contents.\n\n### `#extendJSON(filepath, contents[, replacer [, space]])`\n\nExtend the content of an existing JSON file with the partial objects provided as argument.\n\nOptionally take the same JSON formatting arguments than `#writeJSON()`.\n\n### `#delete(filepath, [options])`\n\nDelete a file or a directory.\n\n`filePath` can also be a `glob`. If `filePath` is glob, you can optionally pass in an `options.globOptions` object to change its pattern matching behavior. The full list of options are being described [here](https://github.com/mrmlnc/fast-glob#options-1). The `sync` flag is forced to be `true` in `globOptions`.\n\n### `#copy(from, to, [options], context[, templateOptions ])`\n\nCopy a file from the `from` path to the `to` path.\n\nOptionally, pass an `options.process` function (`process(contents)`) returning a string or a buffer who'll become the new file content. The process function will take a single contents argument who is the copied file contents as a `Buffer`.\n\n`option.ignoreNoMatch` can be used to silence the error thrown if no files match the `from` pattern.\n\n`from` can be a glob pattern that'll be match against the file system. If that's the case, then `to` must be an output directory. For a globified `from`, you can optionally pass in an `options.globOptions` object to change its pattern matching behavior. The full list of options are being described [here](https://github.com/mrmlnc/fast-glob#options-1). The `nodir` flag is forced to be `true` in `globOptions` to ensure a vinyl object representing each matching directory is marked as `deleted` in the `mem-fs` store.\n\nOptionally, when `from` is a glob pattern, pass an `options.processDestinationPath` function (`processDestinationPath(destinationFile)`) returning a string who'll become the new file name.\n\n### `#copyTpl(from, to, context[, templateOptions [, copyOptions]])`\n\nCopy the `from` file and, if it is not a binary file, parse its content as an [ejs](http://ejs.co/) template where `context` is the template context (the variable names available inside the template).\n\nYou can optionally pass a `templateOptions` object. `mem-fs-editor` automatically setup the filename option so you can easily use partials.\n\nYou can also optionally pass a `copyOptions` object (see [copy() documentation for more details](https://github.com/SBoudrias/mem-fs-editor#copyfrom-to-options)).\n\nTemplates syntax looks like this:\n\n```\n<%= value %>\n<%- include('partial.ejs', { name: 'Simon' }) %>\n```\n\nDir syntax looks like this:\n\n```\n/some/path/dir<%= value %>/...\n```\n\nRefer to the [ejs documentation](http://ejs.co/) for more details.\n\n### `#move(from, to, [options])`\n\nMove/rename a file from the `from` path to the `to` path.\n\n`#move` internally uses `#copy` and `#delete`, so `from` can be a glob pattern, and you can provide `options.globOptions` with it.\n\n### `#exists(filepath)`\n\nReturns `true` if a file exists. Returns `false` if the file is not found or deleted.\n\n### `#commit([filters,] [stream,] callback)`\n\nPersist every changes made to files in the mem-fs store to disk.\n\nIf provided, `filters` is an array of TransformStream to be applied on a stream of vinyl files (like gulp plugins).\nIf provided, `stream` is a stream of vinyl files.\n\n`callback` is called once the files are updated on disk.\n","readmeFilename":"README.md","gitHead":"ec99952f09216c16fdffaca80d2e24a468b763f3","bugs":{"url":"https://github.com/SBoudrias/mem-fs-editor/issues"},"homepage":"https://github.com/SBoudrias/mem-fs-editor#readme","_id":"mem-fs-editor@8.0.0-beta.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-KUyO1CKKvflowdqvZsG+UvrdVr20Az0XHfv1h2rxlmZA9VyzG5LMzxZwW+hiaGOuDh74Zh6d21eR1gADQbmVUw==","shasum":"3b74dc71317deb2611e10f455aa0dc525db7be89","tarball":"http://registry-npm.ywwl.com/mem-fs-editor/download/mem-fs-editor-8.0.0-beta.0.tgz","fileCount":16,"unpackedSize":17610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftBUwCRA9TVsSAnZWagAAqRkP/Au8HklJS2fbXTSc1uQM\nyqd0PX56+30H0nacrNTmGRxvSfY9Vf9KDwRY7m3y78DzXjQ2KAk5Vog0GZZa\nqR4QGP9ab6m4OHIBohccvjQqv3aYLvkPhDiCMmzijsNTcMSQRxmUknh7WlzX\nrnCW0T5OtHMfUbZ4XY7djmxmHUHw/f600sUZ5Fq233DzGLBvJe7N42C4HENM\nXkCSheR02uaCT2gGhViBqM62a9dALs9gb+1BhadvvvCGJ9nk/iJtoOdcmu/p\nB3meLEbgHtsALIPVcL7KNvb+s4+eE0vbrhSFJC0qs0y9SmRQxxvjhPLkJ3d9\nRzuw5bsc/imsBj38MUV8QQeEGUYNZeXs4JXCHLaKvJ9f5NGRa1IdgI/93SHP\nUUx3rIoqUdSU4Y/91fCSfTYIv9oaQhK1bhP7/xBU21IKd9/7SEYOwaTyS54g\nLMRmWCP3U27JVb5t1ed+eSnlPbTHgapwkGzx0eSO34HwNs0EyrM1kCID2HTV\nigTeWFWe/gUjqXMPkH0CQZOg66WQDM2E9RmBbDNcaKFQWDgp4tb22hxYfcXa\n9Mx+KYvILKvsbgctTugpOerPEhf4FOp8ZLGI+z4TByMW4XYTaytT2za+W6LV\njVM4IgdtoXbeXl+Gt/vcQZ7AxWnlabt8L8HqG1zbS200SdT/aR7+GlAGv+mc\n6gL+\r\n=Pdat\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEWwYZLW5DraQKup3sdTX6Ug/A0HyHe3NvUcrPtyTtPfAiAZnw5mLAZSxqQ3Aurjn27EJ6bfHKDS7I+8YfTsBnR8ew=="}],"size":6008,"noattachment":false,"key":"/mem-fs-editor/-/mem-fs-editor-8.0.0-beta.0.tgz"},"_npmUser":{"name":"mshima","email":"marceloshima@gmail.com"},"directories":{},"maintainers":[{"name":"sboudrias","email":"admin@simonboudrias.com"},{"name":"mshima","email":"marceloshima@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mem-fs-editor_8.0.0-beta.0_1605637424319_0.6042379721241393"},"_hasShrinkwrap":false,"publish_time":1605637424470,"_cnpm_publish_time":1605637424470,"dist-tags":{"latest":"12.1.0"}}