Skip to content

Commit

Permalink
Require Node.js 8, change cwd argument to an options-object
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 21, 2019
1 parent f95579d commit 7b8d9cf
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
[*.yml]
indent_style = space
indent_size = 2
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- '6'
- '4'
- '10'
- '8'
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const findUp = require('find-up');

module.exports = cwd => findUp('package.json', {cwd});
module.exports.sync = cwd => findUp.sync('package.json', {cwd});
module.exports = async ({cwd}) => findUp('package.json', {cwd});
module.exports.sync = ({cwd}) => findUp.sync('package.json', {cwd});
20 changes: 4 additions & 16 deletions license
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
96 changes: 48 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "pkg-up",
"version": "2.0.0",
"description": "Find the closest package.json file",
"license": "MIT",
"repository": "sindresorhus/pkg-up",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"pkg",
"package",
"file",
"find",
"up",
"find-up",
"findup",
"look-up",
"look",
"search",
"match",
"resolve",
"parent",
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"dependencies": {
"find-up": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "pkg-up",
"version": "2.0.0",
"description": "Find the closest package.json file",
"license": "MIT",
"repository": "sindresorhus/pkg-up",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"pkg",
"package",
"file",
"find",
"up",
"find-up",
"findup",
"look-up",
"look",
"search",
"match",
"resolve",
"parent",
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"dependencies": {
"find-up": "^3.0.0"
},
"devDependencies": {
"ava": "^1.3.1",
"xo": "^0.24.0"
}
}
20 changes: 12 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Install

```
$ npm install --save pkg-up
$ npm install pkg-up
```


Expand All @@ -27,22 +27,26 @@ $ npm install --save pkg-up
// example.js
const pkgUp = require('pkg-up');

pkgUp().then(filepath => {
console.log(filepath);
(async () => {
console.log(await pkgUp());
//=> '/Users/sindresorhus/foo/package.json'
});
})();
```


## API

### pkgUp([cwd])
### pkgUp([options])

Returns a `Promise` for either the filepath or `null` if it couldn't be found.
Returns a `Promise<string>` for the filepath, or `Promise<null>` if it couldn't be found.

### pkgUp.sync([cwd])
### pkgUp.sync([options])

Returns the filepath or `null`.
Returns the filepath, or `null` if it couldn't be found.

#### options

Type: `Object`

#### cwd

Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from 'path';
import test from 'ava';
import m from '.';
import pkgUp from '.';

const cwd = path.join(__dirname, 'fixture');
const pkgPath = path.join(__dirname, 'package.json');

test('async', async t => {
t.is(await m(cwd), pkgPath);
t.is(await pkgUp({cwd}), pkgPath);
});

test('sync', t => {
t.is(m.sync(cwd), pkgPath);
t.is(pkgUp.sync({cwd}), pkgPath);
});

0 comments on commit 7b8d9cf

Please sign in to comment.