{"_id":"mutate-fs","_rev":"146726","name":"mutate-fs","description":"Mutate the filesystem behavior for tests.","dist-tags":{"latest":"2.1.1"},"maintainers":[{"name":"isaacs","email":""}],"time":{"modified":"2021-06-03T11:30:09.000Z","created":"2017-04-13T17:35:59.151Z","2.1.1":"2017-11-14T01:10:11.457Z","2.1.0":"2017-09-12T06:02:01.722Z","2.0.1":"2017-09-10T03:18:05.747Z","2.0.0":"2017-09-10T03:03:34.952Z","1.1.0":"2017-04-21T07:53:39.949Z","1.0.2":"2017-04-13T17:40:26.793Z","1.0.1":"2017-04-13T17:36:35.527Z","1.0.0":"2017-04-13T17:35:59.151Z"},"users":{},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"repository":{"type":"git","url":"git+https://github.com/isaacs/mutate-fs.git"},"versions":{"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":{"shasum":"164facf0cd500ed7884143ce96b35273c3c1b4cc","size":3741,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-2.1.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.1.1.tgz_1510621811028_0.7139675791841"},"directories":{},"publish_time":1510621811457,"_hasShrinkwrap":false,"_cnpm_publish_time":1510621811457},"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":{"shasum":"db1f06c04492e6de888d17bd6034b06553625c39","size":3690,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-2.1.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.1.0.tgz_1505196121629_0.4854237188119441"},"directories":{},"publish_time":1505196121722,"_hasShrinkwrap":false,"_cnpm_publish_time":1505196121722},"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":{"shasum":"b247729175c5d43638175ac55ac63187e5008f3d","size":3581,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-2.0.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.0.1.tgz_1505013485560_0.646695941220969"},"directories":{},"publish_time":1505013485747,"_hasShrinkwrap":false,"_cnpm_publish_time":1505013485747},"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":{"shasum":"c2917da090d9f72a353bb87a64814b48971a17ad","size":3613,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-2.0.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutate-fs-2.0.0.tgz_1505012614880_0.27427267632447183"},"directories":{},"publish_time":1505012614952,"_hasShrinkwrap":false,"_cnpm_publish_time":1505012614952},"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","size":3530,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-1.1.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/mutate-fs-1.1.0.tgz_1492761219657_0.8617858535144478"},"directories":{},"publish_time":1492761219949,"_hasShrinkwrap":false,"_cnpm_publish_time":1492761219949},"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","size":3343,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-1.0.2.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.2.tgz_1492105224857_0.16476995940320194"},"directories":{},"publish_time":1492105226793,"_hasShrinkwrap":false,"_cnpm_publish_time":1492105226793},"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","size":3343,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-1.0.1.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.1.tgz_1492104993604_0.841531440615654"},"directories":{},"publish_time":1492104995527,"_hasShrinkwrap":false,"_cnpm_publish_time":1492104995527},"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","size":3341,"noattachment":false,"key":"/mutate-fs/-/mutate-fs-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mutate-fs/download/mutate-fs-1.0.0.tgz"},"maintainers":[{"name":"isaacs","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mutate-fs-1.0.0.tgz_1492104957249_0.8368437893223017"},"directories":{},"publish_time":1492104959151,"_cnpm_publish_time":1492104959151,"_hasShrinkwrap":false}},"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","_attachments":{},"homepage":"https://github.com/isaacs/mutate-fs#readme","bugs":{"url":"https://github.com/isaacs/mutate-fs/issues"},"license":"ISC"}