Skip to content

Commit

Permalink
feat: drop read-package-json-fast
Browse files Browse the repository at this point in the history
This removes the `read-package-json-fast` dependency since we don't
actually need the normalisation it provides.

It is soon being merged into npm's CLI package too, meaning we will have
a rather heavy dependency for what's basically the task of reading a
file.

Makes sense to drop it.
  • Loading branch information
43081j committed Mar 5, 2024
1 parent d1686d1 commit 8b4cab9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"main": "./dist/commonjs/main.js",
"types": "./dist/commonjs/main.d.ts",
"dependencies": {
"read-package-json-fast": "^3.0.2",
"walk-up-path": "^3.0.1"
}
}
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {walkUp} from 'walk-up-path';
import {resolve} from 'node:path';
import {stat} from 'node:fs/promises';
import rpj from 'read-package-json-fast';
import {stat, readFile} from 'node:fs/promises';

/**
* Determines if a file exists or not
Expand Down Expand Up @@ -51,5 +50,10 @@ export async function findPackage(cwd: string): Promise<Package | null> {
return null;
}

return rpj(packagePath);
try {
const source = await readFile(packagePath, {encoding: 'utf8'});
return JSON.parse(source);
} catch (_err) {
return null;
}
}

0 comments on commit 8b4cab9

Please sign in to comment.