Skip to content

Commit

Permalink
[utils] [Refactor] inline pkgDir implementation; remove pkg-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 2, 2022
1 parent 210e40a commit 9e06eff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
- [patch] Fix `@babel/eslint-parser` 8 compatibility ([#2343], thanks [@nicolo-ribaudo])

### Changed
- [Refactor] inline `pkgDir` implementation; remove `pkg-dir`

## v2.7.1 - 2021-10-13

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"homepage": "https://github.com/import-js/eslint-plugin-import#readme",
"dependencies": {
"debug": "^3.2.7",
"find-up": "^2.1.0",
"pkg-dir": "^2.0.0"
"find-up": "^2.1.0"
}
}
11 changes: 11 additions & 0 deletions utils/pkgDir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const path = require('path');
const pkgUp = require('./pkgUp').default;

exports.__esModule = true;

exports.default = function (cwd) {
const fp = pkgUp({ cwd });
return fp ? path.dirname(fp) : null;
};
5 changes: 2 additions & 3 deletions utils/resolve.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';
exports.__esModule = true;

const pkgDir = require('pkg-dir');

const fs = require('fs');
const Module = require('module');
const path = require('path');

const hashObject = require('./hash').hashObject;
const ModuleCache = require('./ModuleCache').default;
const pkgDir = require('./pkgDir').default;

const CASE_SENSITIVE_FS = !fs.existsSync(path.join(__dirname.toUpperCase(), 'reSOLVE.js'));
exports.CASE_SENSITIVE_FS = CASE_SENSITIVE_FS;
Expand Down Expand Up @@ -175,7 +174,7 @@ function resolverReducer(resolvers, map) {
}

function getBaseDir(sourceFile) {
return pkgDir.sync(sourceFile) || process.cwd();
return pkgDir(sourceFile) || process.cwd();
}
function requireResolver(name, sourceFile) {
// Try to resolve package with conventional name
Expand Down

0 comments on commit 9e06eff

Please sign in to comment.