Skip to content

Commit

Permalink
chore: switch to find-up from read-pkg-up (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Oct 12, 2017
1 parent cb16460 commit db77c53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,9 +14,9 @@
"dependencies": {
"cliui": "^3.2.0",
"decamelize": "^1.1.1",
"find-up": "^2.1.0",
"get-caller-file": "^1.0.1",
"os-locale": "^2.0.0",
"read-pkg-up": "^2.0.0",
"require-directory": "^2.1.1",
"require-main-filename": "^1.0.1",
"set-blocking": "^2.0.0",
Expand Down
8 changes: 5 additions & 3 deletions yargs.js
@@ -1,5 +1,6 @@
'use strict'
const argsert = require('./lib/argsert')
const fs = require('fs')
const Command = require('./lib/command')
const Completion = require('./lib/completion')
const Parser = require('yargs-parser')
Expand Down Expand Up @@ -494,17 +495,18 @@ function Yargs (processArgs, cwd, parentRequire) {
function pkgUp (path) {
const npath = path || '*'
if (pkgs[npath]) return pkgs[npath]
const readPkgUp = require('read-pkg-up')
const findUp = require('find-up')

let obj = {}
try {
obj = readPkgUp.sync({
const pkgJsonPath = findUp.sync('package.json', {
cwd: path || require('require-main-filename')(parentRequire || require),
normalize: false
})
obj = JSON.parse(fs.readFileSync(pkgJsonPath))
} catch (noop) {}

pkgs[npath] = obj.pkg || {}
pkgs[npath] = obj || {}
return pkgs[npath]
}

Expand Down

0 comments on commit db77c53

Please sign in to comment.