diff --git a/package.json b/package.json index 1e3e32992..21f1abfdf 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "test:watch": "jest --watch" }, "dependencies": { - "app-root-path": "^2.0.1", "chalk": "^2.3.1", "commander": "^2.14.1", "cosmiconfig": "^5.0.2", diff --git a/src/findBin.js b/src/findBin.js index 5d30cbcad..55cd85c6a 100644 --- a/src/findBin.js +++ b/src/findBin.js @@ -1,14 +1,22 @@ 'use strict' const parse = require('string-argv') -const appRoot = require('app-root-path') const npmWhich = require('npm-which')(process.cwd()) const checkPkgScripts = require('./checkPkgScripts') -// Find and load the package.json at the root of the project. -const pkg = require(appRoot.resolve('package.json')) // eslint-disable-line import/no-dynamic-require const debug = require('debug')('lint-staged:find-bin') +// Find and load the package.json at the root of the project. +let pkg +try { + // eslint-disable-next-line import/no-dynamic-require, global-require + pkg = require(`${process.cwd()}/package.json`) + debug('Loaded package.json using `process.cwd()`') +} catch (ignore) { + debug('Could not load package.json using `process.cwd()`') + pkg = {} +} + const cache = new Map() module.exports = function findBin(cmd) { diff --git a/yarn.lock b/yarn.lock index a19a61f0f..9f304e1a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -124,10 +124,6 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -app-root-path@^2.0.1: - version "2.1.0" - resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.1.0.tgz#98bf6599327ecea199309866e8140368fd2e646a" - append-transform@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab"