From 331d10305af3991bd225fbd7a1060bf43cff22d3 Mon Sep 17 00:00:00 2001 From: Shen Yiming Date: Wed, 3 Jan 2018 14:26:21 +0800 Subject: [PATCH] fix: Add `dirname` sanity check on `findUp` (#1036) --- yargs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yargs.js b/yargs.js index 011cc4fe6..524404fb3 100644 --- a/yargs.js +++ b/yargs.js @@ -502,7 +502,7 @@ function Yargs (processArgs, cwd, parentRequire) { let obj = {} try { const pkgJsonPath = findUp.sync('package.json', { - cwd: path || require('require-main-filename')(parentRequire || require), + cwd: path || require('path').dirname(require('require-main-filename')(parentRequire || require)), normalize: false }) obj = JSON.parse(fs.readFileSync(pkgJsonPath))