{"name":"mem-fs-editor","version":"7.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.0.1","glob":"^7.1.4","globby":"^10.0.0","isbinaryfile":"^4.0.0","mkdirp":"^1.0.0","multimatch":"^4.0.0","rimraf":"^3.0.0","through2":"^3.0.1","vinyl":"^2.2.0"},"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":">=10.0.0"},"gitHead":"19d0f5fe1353e2fdd36cd27a0e593b4099f3531f","bugs":{"url":"https://github.com/SBoudrias/mem-fs-editor/issues"},"homepage":"https://github.com/SBoudrias/mem-fs-editor#readme","_id":"mem-fs-editor@7.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-OBqCAsN5DDLapL3BXcpbJyN3Eb52r36nfmcE0jCw5gZZk1IPK9NmXazPeqIFVMkQAc7c2XrUadlPUMCaEsYp9w==","shasum":"ec80120fa6d6ebfabe6a3cf8ffaf64d680b64b81","tarball":"http://registry-npm.ywwl.com/mem-fs-editor/download/mem-fs-editor-7.0.0.tgz","fileCount":16,"unpackedSize":17239,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe1Iq9CRA9TVsSAnZWagAAemYP/A+7TdkTclWipK1bIWnQ\n3FBQzz0jzz7tSRWkGOiX72+Zp1Xz6JTaWPS32g4XnTh0ir4RVGY52B+JGqsp\ntbXEm9O2b7HrGEABMqt0BxRQX/ZuSqPkq+tj+zn9N83F/pBjxS8Xo42mWOt7\nYKRirF2s2p04H/A2F4HMP0ykhODpat9ltZwI9QRpE49TDUJno/W570NSTkbY\nQRFrSzwB3BWBobG8jhll5ucCzHYTefz42jbkMheC51IUfQlV25G2KLXUknVZ\ncNXtD5Soeo73eDGNDzdRZRl+Rk9qwDLdBDjymzehc3Ktt7180NMRNZUE6TKc\nSE8pb+GQefKfkLpsFoOATNbwKr8kS1AvCswzjMVMdDLcfNVz5VQUqFcmGRdG\nh7EK7WX7eEiosk0An7A5ImdmdahjyGhpLn+4NDAUQvTMjVOKmMl9GhlB6pc8\nx590mkPWGbPy9s+72NS00JNIIUxGAgnQzy6Ym8YIOF5bqFDwlLcuu9gNe0OE\nKWMfUx8Jj3BiCWIV9bvky9TY/81Of5RH/1d5SKc4mOll23jD6DDjWSrJ5XDI\naPYFIlu/q+RXPzJR22wF0C7aYIApjXQGJGyhLyHo2wKUWFdfneRb5wVIQ/UU\nEbVR9swoafNRX+i01LTAcOvQOX/veGt7gOCdvpptMrm8kulwTi0S7nq3sH8h\nWl6v\r\n=2SaK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID9XoiaFY6afWSvwVcjbapOThpoS/zi4TB9KYCp9G6+yAiEAlFeWnbcyugBgU8YpKxWpAChWFDgmcFGSPd7eLnrE+IU="}],"size":5919,"noattachment":false,"key":"/mem-fs-editor/-/mem-fs-editor-7.0.0.tgz"},"maintainers":[{"name":"sboudrias","email":"admin@simonboudrias.com"}],"_npmUser":{"name":"sboudrias","email":"admin@simonboudrias.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mem-fs-editor_7.0.0_1590987453406_0.21976951282844315"},"_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":1590987453530,"_cnpm_publish_time":1590987453530,"dist-tags":{"latest":"12.1.0"}}