Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
  • Loading branch information
wraithgar committed Nov 25, 2024
commit 3c5f1c98a5215a3a713b460c5870f0b823e05ba1
12 changes: 11 additions & 1 deletion node_modules/package-json-from-dist/dist/commonjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const node_url_1 = require("node:url");
const NM = `${node_path_1.sep}node_modules${node_path_1.sep}`;
const STORE = `.store${node_path_1.sep}`;
const PKG = `${node_path_1.sep}package${node_path_1.sep}`;
const DIST = `${node_path_1.sep}dist${node_path_1.sep}`;
/**
* Find the package.json file, either from a TypeScript file somewhere not
Expand Down Expand Up @@ -59,8 +61,16 @@ const findPackageJson = (from, pathFromSrc = '../package.json') => {
// inside of node_modules. find the dist directly under package name.
const nm = __dirname.substring(0, nms + NM.length);
const pkgDir = __dirname.substring(nms + NM.length);
// affordance for yarn berry, which puts package contents in
// '.../node_modules/.store/${id}-${hash}/package/...'
if (pkgDir.startsWith(STORE)) {
const pkg = pkgDir.indexOf(PKG, STORE.length);
if (pkg) {
return (0, node_path_1.resolve)(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
}
}
const pkgName = pkgDir.startsWith('@') ?
pkgDir.split(node_path_1.sep).slice(0, 2).join(node_path_1.sep)
pkgDir.split(node_path_1.sep, 2).join(node_path_1.sep)
: String(pkgDir.split(node_path_1.sep)[0]);
return (0, node_path_1.resolve)(nm, pkgName, 'package.json');
}
Expand Down
12 changes: 11 additions & 1 deletion node_modules/package-json-from-dist/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { readFileSync } from 'node:fs';
import { dirname, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
const NM = `${sep}node_modules${sep}`;
const STORE = `.store${sep}`;
const PKG = `${sep}package${sep}`;
const DIST = `${sep}dist${sep}`;
/**
* Find the package.json file, either from a TypeScript file somewhere not
Expand Down Expand Up @@ -56,8 +58,16 @@ export const findPackageJson = (from, pathFromSrc = '../package.json') => {
// inside of node_modules. find the dist directly under package name.
const nm = __dirname.substring(0, nms + NM.length);
const pkgDir = __dirname.substring(nms + NM.length);
// affordance for yarn berry, which puts package contents in
// '.../node_modules/.store/${id}-${hash}/package/...'
if (pkgDir.startsWith(STORE)) {
const pkg = pkgDir.indexOf(PKG, STORE.length);
if (pkg) {
return resolve(nm, pkgDir.substring(0, pkg + PKG.length), 'package.json');
}
}
const pkgName = pkgDir.startsWith('@') ?
pkgDir.split(sep).slice(0, 2).join(sep)
pkgDir.split(sep, 2).join(sep)
: String(pkgDir.split(sep)[0]);
return resolve(nm, pkgName, 'package.json');
}
Expand Down
4 changes: 2 additions & 2 deletions node_modules/package-json-from-dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "package-json-from-dist",
"version": "1.0.0",
"version": "1.0.1",
"description": "Load the local package.json from either src or dist folder",
"main": "./dist/commonjs/index.js",
"exports": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache",
"format": "prettier --write . --log-level warn",
"typedoc": "typedoc"
},
"author": "Isaac Z. Schlueter <[email protected]> (https://izs.me)",
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -12880,9 +12880,9 @@
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz",
"integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
"inBundle": true,
"license": "BlueOak-1.0.0"
},
Expand Down