|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | # pkg-up [](https://travis-ci.org/sindresorhus/pkg-up)
|
|---|
| 2 |
|
|---|
| 3 | > Find the closest package.json file
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | ## Install
|
|---|
| 7 |
|
|---|
| 8 | ```
|
|---|
| 9 | $ npm install pkg-up
|
|---|
| 10 | ```
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | ## Usage
|
|---|
| 14 |
|
|---|
| 15 | ```
|
|---|
| 16 | /
|
|---|
| 17 | └── Users
|
|---|
| 18 | └── sindresorhus
|
|---|
| 19 | └── foo
|
|---|
| 20 | ├── package.json
|
|---|
| 21 | └── bar
|
|---|
| 22 | ├── baz
|
|---|
| 23 | └── example.js
|
|---|
| 24 | ```
|
|---|
| 25 |
|
|---|
| 26 | ```js
|
|---|
| 27 | // example.js
|
|---|
| 28 | const pkgUp = require('pkg-up');
|
|---|
| 29 |
|
|---|
| 30 | (async () => {
|
|---|
| 31 | console.log(await pkgUp());
|
|---|
| 32 | //=> '/Users/sindresorhus/foo/package.json'
|
|---|
| 33 | })();
|
|---|
| 34 | ```
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | ## API
|
|---|
| 38 |
|
|---|
| 39 | ### pkgUp([options])
|
|---|
| 40 |
|
|---|
| 41 | Returns a `Promise<string>` for the filepath, or `Promise<null>` if it couldn't be found.
|
|---|
| 42 |
|
|---|
| 43 | ### pkgUp.sync([options])
|
|---|
| 44 |
|
|---|
| 45 | Returns the filepath, or `null` if it couldn't be found.
|
|---|
| 46 |
|
|---|
| 47 | #### options
|
|---|
| 48 |
|
|---|
| 49 | Type: `Object`
|
|---|
| 50 |
|
|---|
| 51 | #### cwd
|
|---|
| 52 |
|
|---|
| 53 | Type: `string`<br>
|
|---|
| 54 | Default: `process.cwd()`
|
|---|
| 55 |
|
|---|
| 56 | Directory to start from.
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | ## Related
|
|---|
| 60 |
|
|---|
| 61 | - [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
|
|---|
| 62 | - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
|
|---|
| 63 | - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | ## License
|
|---|
| 67 |
|
|---|
| 68 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.