Skip to content

Commit 7ab4939

Browse files
committed
chore: drop package-directory
Empathic can do this with a basic dirname check.
1 parent 961d9b2 commit 7ab4939

File tree

7 files changed

+13
-30
lines changed

7 files changed

+13
-30
lines changed

package-lock.json

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build-info/src/node/file-system.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export class NodeFS extends FileSystem {
7979
/** Node implementation of finding files or directories by walking up parent directories. */
8080
findUpMultiple(name: string | readonly string[], options: findUpOptions = {}): Promise<string[]> {
8181
const results: string[] = []
82-
const normalisedNames = typeof name === 'string' ? [name] : name;
82+
const normalisedNames = typeof name === 'string' ? [name] : name
8383
for (const dir of walkUp(options.cwd ?? '.', options)) {
8484
for (const potentialName of normalisedNames) {
85-
const filePath = join(dir, potentialName);
85+
const filePath = join(dir, potentialName)
8686
if (existsSync(filePath)) {
87-
results.push(filePath);
87+
results.push(filePath)
8888
}
8989
}
9090
}

packages/build/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
"p-locate": "^6.0.0",
102102
"p-map": "^7.0.0",
103103
"p-reduce": "^3.0.0",
104-
"package-directory": "^8.0.0",
105104
"path-exists": "^5.0.0",
106105
"path-type": "^6.0.0",
107106
"pretty-ms": "^9.0.0",

packages/build/src/install/local.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { packageDirectory } from 'package-directory'
1+
import { dirname } from 'path'
2+
3+
import { up as packagePath } from 'empathic/package'
24

35
import { logInstallLocalPluginsDeps } from '../log/messages/install.js'
46

@@ -57,6 +59,7 @@ const hasPackageDir = function ({ packageDir }) {
5759

5860
// We only install dependencies of local plugins that have their own `package.json`
5961
const removeMainRoot = async function (localPluginsOptions, buildDir) {
60-
const mainPackageDir = await packageDirectory({ cwd: buildDir })
62+
const mainPackagePath = packagePath({ cwd: buildDir })
63+
const mainPackageDir = mainPackagePath ? dirname(mainPackagePath) : undefined
6164
return localPluginsOptions.filter(({ packageDir }) => packageDir !== mainPackageDir)
6265
}

packages/edge-bundler/node/package_json.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { fileURLToPath } from 'url'
55
import { file as findUp } from 'empathic/find'
66

77
const getPackagePath = () => {
8-
const packageJsonPath = findUp(
9-
'package.json',
10-
{ cwd: dirname(fileURLToPath(import.meta.url)) },
11-
)
8+
const packageJsonPath = findUp('package.json', { cwd: dirname(fileURLToPath(import.meta.url)) })
129
const packagePath = packageJsonPath ? dirname(packageJsonPath) : undefined
1310

1411
// We should never get here, but let's show a somewhat useful error message.

packages/zip-it-and-ship-it/src/runtimes/node/utils/package_json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const getClosestPackageJson = async (resolveDir: string, boundary?: strin
2929
// We stop traversing if we're about to leave the boundaries of any
3030
// node_modules directory.
3131
if (basename(directory) === 'node_modules') {
32-
break;
32+
break
3333
}
3434

3535
const path = join(directory, 'package.json')

packages/zip-it-and-ship-it/src/runtimes/node/utils/plugin_modules_path.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export const createAliases = (
2222
}
2323

2424
export const getPluginsModulesPath = (srcDir: string): Promise<string | undefined> => {
25-
const result = findUp(`${AUTO_PLUGINS_DIR}node_modules`, { cwd: srcDir });
26-
return Promise.resolve(result);
27-
};
25+
const result = findUp(`${AUTO_PLUGINS_DIR}node_modules`, { cwd: srcDir })
26+
return Promise.resolve(result)
27+
}

0 commit comments

Comments
 (0)