pax_global_header00006660000000000000000000000064134550003330014506gustar00rootroot0000000000000052 comment=9166b423d53ffef572eedf7b62926dcc199df0ae pkg-up-3.1.0/000077500000000000000000000000001345500033300127125ustar00rootroot00000000000000pkg-up-3.1.0/.editorconfig000066400000000000000000000002571345500033300153730ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 pkg-up-3.1.0/.gitattributes000066400000000000000000000000231345500033300156000ustar00rootroot00000000000000* text=auto eol=lf pkg-up-3.1.0/.gitignore000066400000000000000000000000271345500033300147010ustar00rootroot00000000000000node_modules yarn.lock pkg-up-3.1.0/.npmrc000066400000000000000000000000231345500033300140250ustar00rootroot00000000000000package-lock=false pkg-up-3.1.0/.travis.yml000066400000000000000000000000541345500033300150220ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' pkg-up-3.1.0/fixture/000077500000000000000000000000001345500033300144005ustar00rootroot00000000000000pkg-up-3.1.0/fixture/.gitkeep000066400000000000000000000000001345500033300160170ustar00rootroot00000000000000pkg-up-3.1.0/index.d.ts000066400000000000000000000016221345500033300146140ustar00rootroot00000000000000declare namespace pkgUp { interface Options { /** Directory to start from. @default process.cwd() */ readonly cwd?: string; } } declare const pkgUp: { /** Find the closest `package.json` file. @returns The filepath, or `null` if it couldn't be found. @example ``` // / // └── Users // └── sindresorhus // └── foo // ├── package.json // └── bar // ├── baz // └── example.js // example.js import pkgUp = require('pkg-up'); (async () => { console.log(await pkgUp()); //=> '/Users/sindresorhus/foo/package.json' })(); ``` */ (options?: pkgUp.Options): Promise; /** Synchronously find the closest `package.json` file. @returns The filepath, or `null` if it couldn't be found. */ sync(options?: pkgUp.Options): string | null; }; export = pkgUp; pkg-up-3.1.0/index.js000066400000000000000000000003021345500033300143520ustar00rootroot00000000000000'use strict'; const findUp = require('find-up'); module.exports = async ({cwd} = {}) => findUp('package.json', {cwd}); module.exports.sync = ({cwd} = {}) => findUp.sync('package.json', {cwd}); pkg-up-3.1.0/index.test-d.ts000066400000000000000000000003761345500033300155760ustar00rootroot00000000000000import {expectType} from 'tsd'; import pkgUp = require('.'); expectType>(pkgUp()); expectType>(pkgUp({cwd: '.'})); expectType(pkgUp.sync()); expectType(pkgUp.sync({cwd: '.'})); pkg-up-3.1.0/license000066400000000000000000000021251345500033300142570ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (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: 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. pkg-up-3.1.0/package.json000066400000000000000000000013721345500033300152030ustar00rootroot00000000000000{ "name": "pkg-up", "version": "3.1.0", "description": "Find the closest package.json file", "license": "MIT", "repository": "sindresorhus/pkg-up", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "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.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } pkg-up-3.1.0/readme.md000066400000000000000000000023671345500033300145010ustar00rootroot00000000000000# pkg-up [![Build Status](https://travis-ci.org/sindresorhus/pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-up) > Find the closest package.json file ## Install ``` $ npm install pkg-up ``` ## Usage ``` / └── Users └── sindresorhus └── foo ├── package.json └── bar ├── baz └── example.js ``` ```js // example.js const pkgUp = require('pkg-up'); (async () => { console.log(await pkgUp()); //=> '/Users/sindresorhus/foo/package.json' })(); ``` ## API ### pkgUp([options]) Returns a `Promise` for the filepath, or `Promise` if it couldn't be found. ### pkgUp.sync([options]) Returns the filepath, or `null` if it couldn't be found. #### options Type: `Object` #### cwd Type: `string`
Default: `process.cwd()` Directory to start from. ## Related - [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories ## License MIT © [Sindre Sorhus](https://sindresorhus.com) pkg-up-3.1.0/test.js000066400000000000000000000006111345500033300142250ustar00rootroot00000000000000import path from 'path'; import test from 'ava'; import pkgUp from '.'; const cwd = path.join(__dirname, 'fixture'); const pkgPath = path.join(__dirname, 'package.json'); test('async', async t => { t.is(await pkgUp({cwd}), pkgPath); t.is(path.dirname(await pkgUp()), __dirname); }); test('sync', t => { t.is(pkgUp.sync({cwd}), pkgPath); t.is(path.dirname(pkgUp.sync()), __dirname); });