{"name":"mem-fs-editor","version":"8.0.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"},"gitHead":"08c2487009279f8a74da95fd8fa6ea9fdc710e86","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","_nodeVersion":"14.15.0","_npmVersion":"6.14.10","dist":{"integrity":"sha512-0+6Zp44EmPpF01MZOlY0kt7JTndjdvALo4jA7Kk9GPCuqGzGnBmWtcE44Cwzj1aru57IN5/LKIWd1lIvaT6sKw==","shasum":"cd8402fa009df302656422f71831ccd8e30319e7","tarball":"http://registry-npm.ywwl.com/mem-fs-editor/download/mem-fs-editor-8.0.0.tgz","fileCount":16,"unpackedSize":17603,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4j+0CRA9TVsSAnZWagAAd1MP/jhs/df7aBo4xxbUhHji\nXTXJuU0ZfLcKh8zMl39aoQR7dbHwnBtzvao4Kiv0PdHvGmwPbLwGs76Ti9G5\nxZrSyt7GoVdZV7FdCWeQCVHRxIrlTaufD5ubQDSHlFg9uGciI3LmLbqVJuro\nK5az4N1OGhoJonFVsPE0849sBW8/+avvm4LoAFRWp6ROTuJDaA2IwXz2U5jb\njlv0ogGFEM64L416eZOTNEj+X1fcoTmFdBP5MaPxfmzgKAuv0DxxB7mXZLJ5\nJkw5UAZ7vCeQUAGkEjrWN1298GNg+Js5fnTQGCv1agVyYvrOmECYX8w+0vSo\n4CflYA3qfgpbAi8ESn/7b+iN8jlj/V28MTg9G6rf3Twm5rOuMlrZrPUqHidV\ndpof8UyEJp0ZWS341TVNO63I15mEygP0Q6pXYRpFOvWYWBwRq4B5MEjXtwXi\nNWgOy52inAnnag16qdI0OQiVxBrqjrXG72z0rul0P9tXa5YRU39Q8e5Y0Q8Z\nnNMCxc90165t8W8meCPUB4xWzEgcN7uHMJdjT9q6k6batYAeb9qs7GlNUUc3\nMFYTJVebMIXkScGqRPJnuW3dGmSrIB8zqqhKVEbYjeCV+bpVjJcYTGbrYTzC\naq4pB70p7ypJvl8SK2XsDg5rMpshqaboNt78h2CKotUETwa7HxV4F3UaTRtx\nv9OI\r\n=31FA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBt/9S/9N99IJy74CMkJFBTkvvejWsQlr2EtD9FgXBqgIhAJRtjC/h2LtLAU0cx5+puOuh1MVwrT3Fpnawr2jp7jUI"}],"size":6003,"noattachment":false,"key":"/mem-fs-editor/-/mem-fs-editor-8.0.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_1608662963471_0.6874538136665589"},"_hasShrinkwrap":false,"readme":"# mem-fs-editor\n\n[![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)\n[![NPM version](https://badge.fury.io/js/mem-fs-editor.svg)](http://badge.fury.io/js/mem-fs-editor)\n[![Coverage Status](https://codecov.io/gh/SBoudrias/mem-fs-editor/branch/master/graph/badge.svg)](https://codecov.io/gh/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\nimport { create as createMemFs } from 'mem-fs';\nimport { create as createEditor } from 'mem-fs-editor';\n\nconst store = createMemFs();\nconst fs = createEditor(store);\n\nfs.write('somefile.js', 'var a = 1;');\nawait fs.commit()\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- `options.create` (default `false`). Create the file if doesn't exists.\n\n### `#appendTpl(filepath, contents, context[, templateOptions[, [options]])`\n\nAppend the new `contents` to the exsting `filepath` content and parse the new contents as an [ejs](http://ejs.co/) template where `context` is the template context (the variable names available inside the template).\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 file(s) from the `from` path to the `to` path.\nWhen passing array, you should pass `options.fromBasePath` to be used to calculate the `to` relative path. The common directory will be detected and used as `fromBasePath` otherwise.\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`options.ignoreNoMatch` can be used to silence the error thrown if no files match the `from` pattern.\n`options.append` can be used to append `from` contents to `to` instead of copying, when the file is already loaded in mem-fs (safe for regeneration).\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`options.noGlob` can be used to by bypass glob matching entirely. In that case, `from` will directly match file paths against the file system.\n\n### `#copyAsync(from, to, [options], context[, templateOptions ])`\n\nAsync version of `copy`.\n\n`copy` loads `from` to memory and copy its contents to `to`.\n`copyAsync` copies directly from the disk to `to`, falling back to `copy` behavior if the file doesn't exists on disk.\n\nSame parameters of `copy` (see [copy() documentation for more details](#copyfrom-to-options-context-templateoptions-)).\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](#copyfrom-to-options-context-templateoptions-)).\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### `#copyTplAsync(from, to, [options], context[, templateOptions ])`\n\nAsync version of `copyTpl` that uses `copyAsync` instead of `copy`.\n\nCan be used for best performance. Reduces overheads.\n\nSame parameters of `copyTpl` (see [copyTpl() documentation for more details](#copyfrom-to-options-context-templateoptions-)).\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([options,] [...transforms])`\n\nPass stored files through a pipeline and persist every changes made to files in the mem-fs store to disk.\n\nIf provided, `options` is the pipeline options.\nBy default only modified files are passed through the pipeline.\nPass a custom filter `options.filter` to customize files passed through the pipeline.\nIf provided, `...transforms` is a vararg of TransformStream to be applied on a stream of vinyl files (like gulp plugins).\n`commitTransform` is appended to `transforms` and persists modified files to disk, non modified files are passed through.\n\nreturns promise that is resolved once the pipeline is finished.\n\n### `#dump([cwd,] [filter])`\n\nDump files to compare expected result.\nProvide a `cwd` for relative path. Allows to omit temporary path.\nProvide a `filter` function or a pattern to focus on specific files.\n`dump` returns only modified (committed or not) files when no filter or a pattern is provided.\n","publish_time":1608662963572,"_cnpm_publish_time":1608662963572,"dist-tags":{"latest":"12.1.0"}}