diff options
Diffstat (limited to 'node_modules/find-up/index.js')
-rw-r--r-- | node_modules/find-up/index.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/node_modules/find-up/index.js b/node_modules/find-up/index.js index 8e83819ce..939c9553d 100644 --- a/node_modules/find-up/index.js +++ b/node_modules/find-up/index.js @@ -2,9 +2,11 @@ const path = require('path'); const locatePath = require('locate-path'); -module.exports = (filename, opts = {}) => { +module.exports = (filename, opts) => { + opts = opts || {}; + const startDir = path.resolve(opts.cwd || ''); - const {root} = path.parse(startDir); + const root = path.parse(startDir).root; const filenames = [].concat(filename); @@ -23,9 +25,11 @@ module.exports = (filename, opts = {}) => { }); }; -module.exports.sync = (filename, opts = {}) => { +module.exports.sync = (filename, opts) => { + opts = opts || {}; + let dir = path.resolve(opts.cwd || ''); - const {root} = path.parse(dir); + const root = path.parse(dir).root; const filenames = [].concat(filename); @@ -35,9 +39,7 @@ module.exports.sync = (filename, opts = {}) => { if (file) { return path.join(dir, file); - } - - if (dir === root) { + } else if (dir === root) { return null; } |