项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # find-cache-dir [![Build Status](https://travis-ci.org/avajs/find-cache-dir.svg?branch=master)](https://travis-ci.org/avajs/find-cache-dir) [![Coverage Status](https://coveralls.io/repos/github/avajs/find-cache-dir/badge.svg?branch=master)](https://coveralls.io/github/avajs/find-cache-dir?branch=master)
  2. > Finds the common standard cache directory
  3. Recently the [`nyc`](https://github.com/bcoe/nyc) and [`AVA`](https://ava.li) projects decided to standardize on a common directory structure for storing cache information:
  4. ```sh
  5. # nyc
  6. ./node_modules/.cache/nyc
  7. # ava
  8. ./node_modules/.cache/ava
  9. # your-module
  10. ./node_modules/.cache/your-module
  11. ```
  12. This module makes it easy to correctly locate the cache directory according to this shared spec. If this pattern becomes ubiquitous, clearing the cache for multiple dependencies becomes easy and consistent:
  13. ```
  14. rm -rf ./node_modules/.cache
  15. ```
  16. If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below.
  17. ## Install
  18. ```
  19. $ npm install --save find-cache-dir
  20. ```
  21. ## Usage
  22. ```js
  23. const findCacheDir = require('find-cache-dir');
  24. findCacheDir({name: 'unicorns'});
  25. //=> '/user/path/node-modules/.cache/unicorns'
  26. ```
  27. ## API
  28. ### findCacheDir([options])
  29. Finds the cache directory using the supplied options. The algorithm tries to find a `package.json` file, searching every parent directory of the `cwd` specified (or implied from other options). It returns a `string` containing the absolute path to the cache directory, or `null` if `package.json` was never found.
  30. #### options
  31. ##### name
  32. *Required*<br>
  33. Type: `string`
  34. Should be the same as your project name in `package.json`.
  35. ##### files
  36. Type: `Array` `string
  37. An array of files that will be searched for a common parent directory. This common parent directory will be used in lieu of the `cwd` option below.
  38. ##### cwd
  39. Type: `string`<br>
  40. Default `process.cwd()`
  41. Directory to start searching for a `package.json` from.
  42. ##### create
  43. Type: `boolean`<br>
  44. Default `false`
  45. If `true`, the directory will be created synchronously before returning.
  46. ##### thunk
  47. Type: `boolean`<br>
  48. Default `false`
  49. If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`.
  50. ```js
  51. const thunk = findCacheDir({name: 'foo', thunk: true});
  52. thunk();
  53. //=> '/some/path/node_modules/.cache/foo'
  54. thunk('bar.js')
  55. //=> '/some/path/node_modules/.cache/foo/bar.js'
  56. thunk('baz', 'quz.js')
  57. //=> '/some/path/node_modules/.cache/foo/baz/quz.js'
  58. ```
  59. This is helpful for actually putting actual files in the cache!
  60. ## Adopters
  61. - [`AVA`](https://ava.li)
  62. - [`nyc`](https://github.com/bcoe/nyc)
  63. - [`babel-loader`](https://github.com/babel/babel-loader)
  64. - [`eslint-loader`](https://github.com/MoOx/eslint-loader)
  65. - [`Phenomic`](https://phenomic.io)
  66. ## License
  67. MIT © [James Talmage](https://github.com/jamestalmage)