{"_id":"mutate-fs","_rev":"10-405d23604a919070e949ce2a54a37205","name":"mutate-fs","description":"Mutate the filesystem behavior for tests.","dist-tags":{"latest":"2.1.1"},"versions":{"1.0.0":{"name":"mutate-fs","version":"1.0.0","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.3.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"c1a49d0f4ca7d1eff90942818491ea8bf0fb5d65","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@1.0.0","_shasum":"480ab5acd47d74058c8524602f19652453cda9ef","_from":".","_npmVersion":"4.5.0","_nodeVersion":"8.0.0-pre","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"480ab5acd47d74058c8524602f19652453cda9ef","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-1.0.0.tgz","integrity":"sha512-UF3TI8na70PGE6YKUNas8yMn0u3hEtnnZPrHXgxo6hs4m/xi2J/ssGJStSAN//3wgCkyCASa6XURpLLmYSl/bg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWC2xO18nxHB3u07cVMgjTM/+D0hkn9f3MPIzmw9zUxQIgFtoktZxaCdIrjTBqkHkeXJgdb4sikMn9/UG+rJOSEN8="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.0.tgz_1492104957249_0.8368437893223017"}},"1.0.1":{"name":"mutate-fs","version":"1.0.1","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.3.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"ddf459f63b9b680322f7885f9a845223ef04263c","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@1.0.1","_shasum":"515efeaac0d15447d0afe67d48a94bbfdbd15d7f","_from":".","_npmVersion":"4.5.0","_nodeVersion":"8.0.0-pre","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"515efeaac0d15447d0afe67d48a94bbfdbd15d7f","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-1.0.1.tgz","integrity":"sha512-RqPbGIaJrfbDFU46lOiKTXRO3WygFP59XmYU3y4UUbS9lVU9Tlktpl8QNxWzNMKTm+svccIp2aymEgL32B2t0g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDw4cFmIjuIMOZtjX7n83L3mSqUaAHFBxqYaTGWun33wQIgPHWrvI7/fwTOl/JlAezmcvtySQ/WPI9D83Y5K7dvdhw="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.1.tgz_1492104993604_0.841531440615654"}},"1.0.2":{"name":"mutate-fs","version":"1.0.2","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.3.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"c4f4660575847756d5766ff89bff2a6455186b9e","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@1.0.2","_shasum":"49755455283b4b240431820002c2638008480fef","_from":".","_npmVersion":"4.5.0","_nodeVersion":"8.0.0-pre","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"49755455283b4b240431820002c2638008480fef","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-1.0.2.tgz","integrity":"sha512-6xScdIzAm8oOzLDHyyypKr8phZFmI4oi90cei+/+mHIjlQEtU5dHM74lrRHJmCvx7U7pD8Iwrp3IvHmCN/1I2g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGnvYw0cyf9CQW8uWkO/gZXZl9Md3QoSWqS56qUpLJjsAiEAjWFBb3xFHa1PNFIWYyktgUKgM/49crKmtGVV0FlU+Yg="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.2.tgz_1492105224857_0.16476995940320194"}},"1.1.0":{"name":"mutate-fs","version":"1.1.0","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.3.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"8fac23fc7d42e51f70e07da0ce64eec30129de4c","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@1.1.0","_shasum":"c87ed575f10c45493e0c0c126048de01c3b80f20","_from":".","_npmVersion":"4.5.0","_nodeVersion":"8.0.0-pre","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"shasum":"c87ed575f10c45493e0c0c126048de01c3b80f20","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-1.1.0.tgz","integrity":"sha512-s4Zir41W2Sk9XkHto6hD39JTviRfrwSCurl7E1gOSe4HDRh822JLRGUO434Tq/jgEs6ewg1TuB8cazMHHhnnnA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDcQrUqoVNMEHwgM+ecH9XiINQU16veFZ6FxqKESZFMQIhAMMNslMwzx7d4pcNf0F2/e7wYu73kHShh9k19aAMCgIA"}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/mutate-fs-1.1.0.tgz_1492761219657_0.8617858535144478"}},"2.0.0":{"name":"mutate-fs","version":"2.0.0","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.7.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"d1c766b6287fbcd6d3ee2b7768b3026880ddec05","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@2.0.0","_npmVersion":"5.4.1","_nodeVersion":"8.2.1","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"integrity":"sha512-HSzYxnvOwTc8/NJpd1XhmKy10LuTOFDPVBJGMayqoQtQrm8WXhnOAkcLMC17n6ZaOuIgHaN8hb5yD5rBU9HUNg==","shasum":"c2917da090d9f72a353bb87a64814b48971a17ad","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-2.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6r9CJmbYos9EjeNrmSM7fBOffjI77Z7Te9bsuFiE7pwIhAIk/AyDYcUgheiTLswW7NShaoeBqdWE65Dli6sYWlfN5"}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.0.0.tgz_1505012614880_0.27427267632447183"}},"2.0.1":{"name":"mutate-fs","version":"2.0.1","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.7.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"68bea5d712a8804b55a4c51dbe82f4a364f48973","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@2.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"integrity":"sha512-upIbJgHP2yd3hlwcWGUAoq5+8QmPR9sZIJGBNiVgORJKQ3BmGvDBevcCJ+Sk+75MrUagTUucADRpwR692qygeA==","shasum":"b247729175c5d43638175ac55ac63187e5008f3d","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-2.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuYhlf/oszrDLIuOU/dzsB6IzX3E5fePQ7x12tv/NepAIgQQH/1q2jKYKQyQC3aNaTHnsU/GZyYQxiSEhCWZW+jtU="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.0.1.tgz_1505013485560_0.646695941220969"}},"2.1.0":{"name":"mutate-fs","version":"2.1.0","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.7.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"b3bed92d4d5112179247d739a5ee7897a7375a14","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@2.1.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"integrity":"sha512-Xmt4qR72m1QyqrJXYsHzh3CAZA++f4PyRj6nIhCchbz70Vwj+OgE9wVPKWYaM+Y38a4a313X9Q51h/Ajn1riNw==","shasum":"db1f06c04492e6de888d17bd6034b06553625c39","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-2.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE9Rb+wCIb6eavCLEdEPkAB1bvS5G1bC2p8WSTKaMq1zAiBxaigUng7yctNpRtZwdo7rMB/67q1ZsX/t9s3cK8Io7g=="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.1.0.tgz_1505196121629_0.4854237188119441"}},"2.1.1":{"name":"mutate-fs","version":"2.1.1","description":"Mutate the filesystem behavior for tests.","main":"index.js","devDependencies":{"tap":"^10.7.2"},"scripts":{"test":"tap test/*.js --100","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"keywords":["file system","munge","mutate","mock","fs"],"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","files":["index.js"],"gitHead":"81dcfd8f28862440b6fe41a327b3d1841e8cd328","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"homepage":"https://github.com/isaacs/mutate-fs#readme","_id":"mutate-fs@2.1.1","_npmVersion":"5.5.1","_nodeVersion":"8.7.0","_npmUser":{"name":"isaacs","email":"i@izs.me"},"dist":{"integrity":"sha512-WI5pPPUNiWqaK2XdK94AVpxIc8GmZEXYlLfFbWuc4gUtBGHTK92jdPqFdx/lilxgb5Ep7tQ15NqCcJEOeq6wdA==","shasum":"164facf0cd500ed7884143ce96b35273c3c1b4cc","tarball":"https://registry.npmjs.org/mutate-fs/-/mutate-fs-2.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDeHhnWL+XeiX0LnpNz6jvm7kTmfiLrGxeeZkYwgNDq8wIgNWp22t8a5V751+n5+rB7jvPmr4Wsp6ez0B5yJSCAI3Y="}]},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.1.1.tgz_1510621811028_0.7139675791841"}}},"readme":"# mutate-fs\n\nMutate the filesystem behavior for tests.\n\n![X-Men](xmen.gif \"mutants\")\n\nThis is not a full-fledged filesystem mock library as much as it is a\nway to just modify the data that's returned, especially to trigger\ncases where the fs is a bit of a jerk, and you want to make sure your\ncode handles it properly.\n\nAll of the methods return a function that restores the default\nbehavior.\n\nYou should probably not use this module outside of a test environment.\nBy design, it does bad things that will probably break stuff.\n\n## USAGE\n\n```js\nconst mutateFS = require('mutate-fs')\n\n// you can of course us this with any test harness,\n// including \"plain old assert\", but showing TAP because I like it.\n\nconst t = require('tap')\n\nt.test('test what happens when stat fails', t => {\n  // restore normalcy after this test\n  t.tearDown(mutateFS.statFail(new Error('pwn')))\n\n  // verify that statting this file (which exists) throws our error\n  t.throws(_ => {\n    fs.statSync(__filename)\n  }, new Error('pwn'))\n\n  t.end()\n})\n\n// plain-old-assert example\n// make stat lie\nconst restore = mutateFS.statType('Directory')\nconst assert = require('assert')\nassert(fs.statSync(__filename).isDirectory())\nrestore()\nassert(fs.statSync(__filename).isFile())\n```\n\n## METHODS\n\n### fail(method, error)\n\nWhenever `fs[method]` is called, call the callback with the supplied\nerror.  Whenever `fs[methodSync]` is called, throw the supplied error.\n\nNote that this means that the actual underlying fs method is not called.\n\nError is decorated with a `callstack` string, which is the stack where\nthe fail method was actually called from.\n\n### pass(method, data)\n\nThe oppose of `fail`.  Whenever `fs[method]` is called, call the\ncallback with the supplied data and no error.  Whenever\n`fs[methodSync]` is called, return the supplied data.\n\nNote that this means that the actual underlying fs method is not called.\n\n### mutate(method, fn)\n\nWhenever `fs[method]` or `fs[methodSync]` is called, apply the\n`fn(error, data)` to the results.\n\n`fn` can either mutate the data in-place (and return nothing) or can\nreturn a `[error, data]` array which is treated as the new result.\n\n### mutateArgs(method, fn)\n\nMutate the arguments passed _into_ the fs method specified.\n\n`fn` takes an array of arguments, and should return the munged set of\narguments to call the method with.\n\n### zenoRead()\n\nMake all `read()` calls appear to return half as many bytes.  This\nexercises frequently overlooked edge cases in many programs that call\n`fs.read()` directly.\n\nAs of version 2, this works by modifying the `length` argument passed\nto `fs.read` and `fs.readSync'.  In version 1.x of this library, it\nonly modified the _reported_ number of bytes read, limiting its\nutility for testing shortened non-positioned (file-scanning) reads.\n\nThe name is a reference to [Zeno's Paradox of Achilles and the\nTortoise](https://en.wikipedia.org/wiki/Zeno%27s_paradoxes#Achilles_and_the_tortoise).\n\n### delay(method, ms)\n\nDelay calls to fs[method] by the specified number of milliseconds.\n\nDelays sync calls by doing a bunch of unnecessary file reads in a\nbusy-loop.\n\n### statFail(error)\n\nLike `fail()`, but called on all three of fstat, lstat, and stat.\n\n### statMutate(fn)\n\nLike `mutate()`, but called on all three of fstat, lstat, and stat.\n\n### statType(type)\n\nMutate stat, lstat, and fstat return values to make them appear to be\nthe provided type.  That is, `stat.is<Type>` will return true.\n\nType must be one of: `'File'`, `'Directory'`, `'CharacterDevice'`,\n`'BlockDevice'`, `'FIFO'`, `'SymbolicLink'`, or `'Socket'`.\n","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"time":{"modified":"2022-06-20T14:49:04.404Z","created":"2017-04-13T17:35:59.151Z","1.0.0":"2017-04-13T17:35:59.151Z","1.0.1":"2017-04-13T17:36:35.527Z","1.0.2":"2017-04-13T17:40:26.793Z","1.1.0":"2017-04-21T07:53:39.949Z","2.0.0":"2017-09-10T03:03:34.952Z","2.0.1":"2017-09-10T03:18:05.747Z","2.1.0":"2017-09-12T06:02:01.722Z","2.1.1":"2017-11-14T01:10:11.457Z"},"homepage":"https://github.com/isaacs/mutate-fs#readme","keywords":["file system","munge","mutate","mock","fs"],"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"license":"ISC","readmeFilename":"README.md"}