From 19c1cf998d7e0f38642b5e79392a38727c243a64 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 19 May 2016 19:33:46 +0700 Subject: [PATCH] meta tweaks --- .editorconfig | 3 --- .travis.yml | 3 ++- index.js | 1 + package.json | 9 ++++++--- readme.md | 44 +++++++++++++++++++++++--------------------- test.js | 8 +++----- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8f9d77e..98a761d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,3 @@ insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/.travis.yml b/.travis.yml index e978cfc..820cf60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: node_js node_js: - - 'stable' + - '6' + - '5' - '4' - '0.12' - '0.10' diff --git a/index.js b/index.js index 8592862..1bc421c 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ var mkdirp = require('mkdirp'); module.exports = function (options) { var name = options.name; var dir = options.cwd; + if (options.files) { dir = commonDir(dir, options.files); } else { diff --git a/package.json b/package.json index a18511f..4ae84ad 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.1", "description": "My well-made module", "license": "MIT", - "repository": "jamestalmage/find-cache-dir", + "repository": "avajs/find-cache-dir", "author": { "name": "James Talmage", "email": "james@talmage.io", @@ -21,7 +21,10 @@ "keywords": [ "cache", "directory", - "dir" + "dir", + "caching", + "find", + "search" ], "dependencies": { "commondir": "^1.0.1", @@ -33,6 +36,6 @@ "coveralls": "^2.11.6", "nyc": "^6.2.1", "rimraf": "^2.5.0", - "xo": "^0.13.0" + "xo": "^0.15.1" } } diff --git a/readme.md b/readme.md index d0b71b1..6b82966 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,8 @@ -# find-cache-dir [![Build Status](https://travis-ci.org/jamestalmage/find-cache-dir.svg?branch=master)](https://travis-ci.org/jamestalmage/find-cache-dir) [![Coverage Status](https://coveralls.io/repos/jamestalmage/find-cache-dir/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamestalmage/find-cache-dir?branch=master) +# 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) -> Finds the common standard cache directory. +> Finds the common standard cache directory -Recently the [`nyc`](https://www.npmjs.com/package/nyc) and [`AVA`](https://www.npmjs.com/package/ava) projects decided to standardize on a common directory structure for storing cache information: +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: ```sh # nyc @@ -16,12 +16,12 @@ Recently the [`nyc`](https://www.npmjs.com/package/nyc) and [`AVA`](https://www. ``` 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: - + ``` rm -rf ./node_modules/.cache ``` -If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below. +If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below. ## Install @@ -37,7 +37,7 @@ $ npm install --save find-cache-dir const findCacheDir = require('find-cache-dir'); findCacheDir({name: 'unicorns'}); -//=> /user/path/node-modules/.cache/unicorns +//=> '/user/path/node-modules/.cache/unicorns' ``` @@ -45,40 +45,40 @@ findCacheDir({name: 'unicorns'}); ### findCacheDir([options]) -Finds the cache dir 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. +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. #### options ##### name -*Required* -Type: `string` +*Required*
+Type: `string` -This should be the same as your project name in `package.json`. +Should be the same as your project name in `package.json`. ##### files -Type: `array` of `string` +Type: `Array` `string 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. ##### cwd -Type: `string` +Type: `string`
Default `process.cwd()` -The directory to start searching for a `package.json` from. +Directory to start searching for a `package.json` from. ##### create -Type: `boolean` +Type: `boolean`
Default `false` If `true`, the directory will be created synchronously before returning. ##### thunk -Type: `boolean` +Type: `boolean`
Default `false` If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`. @@ -87,22 +87,24 @@ If `true`, this modifies the return type to be a function that is a thunk for `p const thunk = findCacheDir({name: 'foo', thunk: true}); thunk(); -//=> /some/path/node_modules/.cache/foo +//=> '/some/path/node_modules/.cache/foo' thunk('bar.js') -//=> /some/path/node_modules/.cache/foo/bar.js +//=> '/some/path/node_modules/.cache/foo/bar.js' thunk('baz', 'quz.js') -//=> /some/path/node_modules/.cache/foo/baz/quz.js +//=> '/some/path/node_modules/.cache/foo/baz/quz.js' ``` This is helpful for actually putting actual files in the cache! + ## Adopters -- [`NYC`](https://www.npmjs.com/package/nyc) -- [`AVA`](https://www.npmjs.com/package/ava) +- [`nyc`](https://github.com/bcoe/nyc) +- [`AVA`](https://ava.li) + ## License -MIT © [James Talmage](http://github.com/jamestalmage) +MIT © [James Talmage](https://github.com/jamestalmage) diff --git a/test.js b/test.js index b046561..43b3548 100644 --- a/test.js +++ b/test.js @@ -1,10 +1,8 @@ -import _test from 'ava'; -import fn from './'; +import fs from 'fs'; import path from 'path'; import rimraf from 'rimraf'; -import fs from 'fs'; - -const test = _test.serial; +import {serial as test} from 'ava'; +import fn from './'; test('finds from a list of files', t => { process.chdir(path.join(__dirname, '..'));