Skip to content

Commit ef1c368

Browse files
committed
deps: package-json-from-dist@1.0.1
1 parent 92e6f07 commit ef1c368

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

node_modules/package-json-from-dist/dist/commonjs/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const node_fs_1 = require("node:fs");
55
const node_path_1 = require("node:path");
66
const node_url_1 = require("node:url");
77
const NM = `${node_path_1.sep}node_modules${node_path_1.sep}`;
8+
const STORE = `.store${node_path_1.sep}`;
9+
const PKG = `${node_path_1.sep}package${node_path_1.sep}`;
810
const DIST = `${node_path_1.sep}dist${node_path_1.sep}`;
911
/**
1012
* Find the package.json file, either from a TypeScript file somewhere not
@@ -59,8 +61,16 @@ const findPackageJson = (from, pathFromSrc = '../package.json') => {
5961
// inside of node_modules. find the dist directly under package name.
6062
const nm = __dirname.substring(0, nms + NM.length);
6163
const pkgDir = __dirname.substring(nms + NM.length);
64+
// affordance for yarn berry, which puts package contents in
65+
// '.../node_modules/.store/${id}-${hash}/package/...'
66+
if (pkgDir.startsWith(STORE)) {
67+
const pkg = pkgDir.indexOf(PKG, STORE.length);
68+
if (pkg) {
69+
return (0, node_path_1.resolve)(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
70+
}
71+
}
6272
const pkgName = pkgDir.startsWith('@') ?
63-
pkgDir.split(node_path_1.sep).slice(0, 2).join(node_path_1.sep)
73+
pkgDir.split(node_path_1.sep, 2).join(node_path_1.sep)
6474
: String(pkgDir.split(node_path_1.sep)[0]);
6575
return (0, node_path_1.resolve)(nm, pkgName, 'package.json');
6676
}

node_modules/package-json-from-dist/dist/esm/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { readFileSync } from 'node:fs';
22
import { dirname, resolve, sep } from 'node:path';
33
import { fileURLToPath } from 'node:url';
44
const NM = `${sep}node_modules${sep}`;
5+
const STORE = `.store${sep}`;
6+
const PKG = `${sep}package${sep}`;
57
const DIST = `${sep}dist${sep}`;
68
/**
79
* Find the package.json file, either from a TypeScript file somewhere not
@@ -56,8 +58,16 @@ export const findPackageJson = (from, pathFromSrc = '../package.json') => {
5658
// inside of node_modules. find the dist directly under package name.
5759
const nm = __dirname.substring(0, nms + NM.length);
5860
const pkgDir = __dirname.substring(nms + NM.length);
61+
// affordance for yarn berry, which puts package contents in
62+
// '.../node_modules/.store/${id}-${hash}/package/...'
63+
if (pkgDir.startsWith(STORE)) {
64+
const pkg = pkgDir.indexOf(PKG, STORE.length);
65+
if (pkg) {
66+
return resolve(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
67+
}
68+
}
5969
const pkgName = pkgDir.startsWith('@') ?
60-
pkgDir.split(sep).slice(0, 2).join(sep)
70+
pkgDir.split(sep, 2).join(sep)
6171
: String(pkgDir.split(sep)[0]);
6272
return resolve(nm, pkgName, 'package.json');
6373
}

node_modules/package-json-from-dist/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "package-json-from-dist",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Load the local package.json from either src or dist folder",
55
"main": "./dist/commonjs/index.js",
66
"exports": {
@@ -28,7 +28,7 @@
2828
"presnap": "npm run prepare",
2929
"test": "tap",
3030
"snap": "tap",
31-
"format": "prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache",
31+
"format": "prettier --write . --log-level warn",
3232
"typedoc": "typedoc"
3333
},
3434
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",

package-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12880,9 +12880,9 @@
1288012880
}
1288112881
},
1288212882
"node_modules/package-json-from-dist": {
12883-
"version": "1.0.0",
12884-
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz",
12885-
"integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==",
12883+
"version": "1.0.1",
12884+
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
12885+
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
1288612886
"inBundle": true,
1288712887
"license": "BlueOak-1.0.0"
1288812888
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy