{"name":"test-fixture","version":"1.0.0","description":"Copy test-fixtures to temp dir and get resolved file paths.","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/kaelzhang/node-test-fixture.git"},"keywords":["test","fixtures","resolve","copy","temp","tmp"],"engines":{"node":">=0.11.0"},"author":{"name":"kael"},"license":"MIT","bugs":{"url":"https://github.com/kaelzhang/node-test-fixture/issues"},"devDependencies":{"mocha":"*","chai":"*"},"dependencies":{"underscore":"~1.6.0","tmp":"0.0.23","fs-extra":"~0.9.1"},"homepage":"https://github.com/kaelzhang/node-test-fixture","_id":"test-fixture@1.0.0","dist":{"shasum":"880cc0fcf91858823724b593558f2f51255e28c3","tarball":"http://registry-npm.ywwl.com/test-fixture/download/test-fixture-1.0.0.tgz","integrity":"sha512-EhFWefmOwvVll5O4UootPUHuVLAWZtHMHkxvYKkIikKlbfZpr7PIpI38z9dK7j6xZpOr3xf4GYVG9Z5/J7xp8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSxvkbzlmZRV6NHyjkbVTIgNkLVeoYXTWxFFGxp9LPKwIhAKES2tSajs9iju7iVePNCyHQhbb2e5hXNQq2YBkjd1J2"}],"size":3690,"noattachment":false,"key":"/test-fixture/-/test-fixture-1.0.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"kael","email":"i@kael.me"},"maintainers":[{"name":"kael","email":"i@kael.me"}],"directories":{},"readme":"[![Build Status](https://travis-ci.org/kaelzhang/node-test-fixture.svg?branch=master)](https://travis-ci.org/kaelzhang/node-test-fixture)\n[![Coverage](https://codecov.io/gh/kaelzhang/node-test-fixture/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/node-test-fixture)\n\n# test-fixture\n\nCopy test fixtures to a temp dir and get resolved file paths.\n\n### Why?\n\nI am tired of writing these:\n\n```js\npath.resolve(__dirname, 'test', 'fixtures')\ntmp.dir(callback)\nfse.copy(fixtures, dir)\npath.join(fixtures, 'some-file.js')\n```\n\n**EVERY DAY!**\n\nSo, I got this.\n\n## Install\n\n```bash\n$ npm i test-fixture -D\n```\n\n## Usage\n\n```js\n// By default, it will use 'test/fixtures' dir.\nconst {copy, resolve} = require('test-fixture')()\n\n// copy 'test/fixtures' to the temp dir\n;(async () => {\n  await copy()\n  console.log(resolve('foo.js'))\n  // '/<temp-dir>/foo.js'\n})\n```\n\n### fixtures(...paths): {resolve, copy, install, root}\n\n- **paths** `Array<path>` to define the root paths of the fixtures, which is similar as\n\nDefines the root of the fixture\n\n```js\nconst path = require('path')\nconst fixturesRoot = path.resolve(projectRoot, 'test', 'fixtures')\n\npath.resolve(fixturesRoot, ...paths)\n```\n\n`...paths` | `base`(dir of test fixtures)\n--------- | --------------------\n`undefined` | `test/fixtures`\n`'a'` | `test/fixtures/a`\n`'a'`, `'b'` | `test/fixtures/a/b`\n`'/path/to'` (absolute) | `/path/to`\n`'/path/to'` (absolute), `'a'` | `/path/to/a`\n\nActually, the `base` is `path.resolve('text/fixtures', ...paths)`\n\n#### Without copying\n\n```js\nconst {resolve} = fixtures(p)\nresolve('a.js')  // -> /path/to/<p>/a.js\n```\n\n#### Using `.copy()`\n\n```js\nconst {copy, resolve} = fixtures(p)\n\nawait copy('/path/to')\n\nresolve('a.js') // -> /path/to/a.js\n```\n\n### await copy(options?)\n### await copy(to?)\n\n- **options?** `Object`\n  - **to?** `path=` the destination folder where the test fixtures will be copied to. If not specified, a temporary directory will be used.\n  - **clean?** `boolean=false` whether should clean the directory `to` if `options.to` is specified.\n  - **install?** `boolean=false` whether should run npm install after copying\n\nCopy the test fixtures into another directory.\n\n```js\ncopy('/path/to')\n\n// is equivalent to\ncopy({\n  to: '/path/to',\n  install: false\n})\n```\n\n### resolve(...paths)\n\nResolves the paths to get the path of the test fixtures\n\nAfter `.copy()`ed, it will resolve paths based on the destination dir.\n\nIf not, it will use the base dir. But never use both of them simultaneously.\n\n```\n/path/to/<base>\n             |-- a.js\n/path/to/<to>\n           |-- a.js\n```\n\n### await install(options?)\n\n- **options?** `Object` options of [`npminstall`](https://npmjs.org/package/npminstall)\n\nInstall packages in the working directory. If run after `await copy()`, then it will install packages in the directory which fixtures copied to.\n\n### getter: root `string`\n\nThe fixture root `/<project-root>/test/fixtures`\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1402205176881,"_cnpm_publish_time":1402205176881,"dist-tags":{"latest":"2.4.1"}}