-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
198c9fe
commit aeafb93
Showing
7 changed files
with
67 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import {dirname} from 'node:path'; | ||
import path from 'node:path'; | ||
import {findUp, findUpSync} from 'find-up'; | ||
|
||
export async function pkgDir(cwd) { | ||
export async function packageDirectory({cwd}) { | ||
const filePath = await findUp('package.json', {cwd}); | ||
return filePath && dirname(filePath); | ||
return filePath && path.dirname(filePath); | ||
} | ||
|
||
export function pkgDirSync(cwd) { | ||
export function packageDirectorySync({cwd}) { | ||
const filePath = findUpSync('package.json', {cwd}); | ||
return filePath && dirname(filePath); | ||
return filePath && path.dirname(filePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {expectType} from 'tsd'; | ||
import {pkgDir, pkgDirSync} from './index.js'; | ||
import {packageDirectory, packageDirectorySync} from './index.js'; | ||
|
||
expectType<Promise<string>>(pkgDir('/Users/project/pkg-dir')); | ||
expectType<string>(pkgDirSync('/Users/project/pkg-dir')); | ||
expectType<Promise<string>>(packageDirectory({cwd: '/Users/project/pkg-dir'})); | ||
expectType<string>(packageDirectorySync({cwd: '/Users/project/pkg-dir'})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,16 @@ | |
"description": "Find the root directory of a Node.js project or npm package", | ||
"license": "MIT", | ||
"repository": "sindresorhus/pkg-dir", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -40,7 +42,6 @@ | |
"parents", | ||
"folder", | ||
"directory", | ||
"dir", | ||
"walk", | ||
"walking", | ||
"path" | ||
|
@@ -52,6 +53,7 @@ | |
"ava": "^3.15.0", | ||
"tempy": "^2.0.0", | ||
"tsd": "^0.17.0", | ||
"typescript": "^4.4.3", | ||
"xo": "^0.44.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters