format: prettify entire project
This commit is contained in:
12
node_modules/package-json-from-dist/dist/commonjs/index.d.ts
generated
vendored
12
node_modules/package-json-from-dist/dist/commonjs/index.d.ts
generated
vendored
@ -41,7 +41,10 @@
|
||||
* console.log(`package.json found at ${pj}`)
|
||||
* ```
|
||||
*/
|
||||
export declare const findPackageJson: (from: string | URL, pathFromSrc?: string) => string;
|
||||
export declare const findPackageJson: (
|
||||
from: string | URL,
|
||||
pathFromSrc?: string
|
||||
) => string;
|
||||
/**
|
||||
* Load the package.json file, either from a TypeScript file somewhere not
|
||||
* in a 'dist' folder, or a built and/or installed 'dist' folder.
|
||||
@ -85,5 +88,8 @@ export declare const findPackageJson: (from: string | URL, pathFromSrc?: string)
|
||||
* console.log(`Hello from ${pj.name}@${pj.version}`)
|
||||
* ```
|
||||
*/
|
||||
export declare const loadPackageJson: (from: string | URL, pathFromSrc?: string) => any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
export declare const loadPackageJson: (
|
||||
from: string | URL,
|
||||
pathFromSrc?: string
|
||||
) => any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
|
87
node_modules/package-json-from-dist/dist/commonjs/index.js
generated
vendored
87
node_modules/package-json-from-dist/dist/commonjs/index.js
generated
vendored
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.loadPackageJson = exports.findPackageJson = void 0;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const node_path_1 = require("node:path");
|
||||
const node_url_1 = require("node:url");
|
||||
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}`;
|
||||
@ -52,38 +52,45 @@ const DIST = `${node_path_1.sep}dist${node_path_1.sep}`;
|
||||
* ```
|
||||
*/
|
||||
const findPackageJson = (from, pathFromSrc = '../package.json') => {
|
||||
const f = typeof from === 'object' || from.startsWith('file://') ?
|
||||
(0, node_url_1.fileURLToPath)(from)
|
||||
: from;
|
||||
const __dirname = (0, node_path_1.dirname)(f);
|
||||
const nms = __dirname.lastIndexOf(NM);
|
||||
if (nms !== -1) {
|
||||
// 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, 2).join(node_path_1.sep)
|
||||
: String(pkgDir.split(node_path_1.sep)[0]);
|
||||
return (0, node_path_1.resolve)(nm, pkgName, 'package.json');
|
||||
const f =
|
||||
typeof from === 'object' || from.startsWith('file://') ?
|
||||
(0, node_url_1.fileURLToPath)(from)
|
||||
: from;
|
||||
const __dirname = (0, node_path_1.dirname)(f);
|
||||
const nms = __dirname.lastIndexOf(NM);
|
||||
if (nms !== -1) {
|
||||
// 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'
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// see if we are in a dist folder.
|
||||
const d = __dirname.lastIndexOf(DIST);
|
||||
if (d !== -1) {
|
||||
return (0, node_path_1.resolve)(__dirname.substring(0, d), 'package.json');
|
||||
}
|
||||
else {
|
||||
return (0, node_path_1.resolve)(__dirname, pathFromSrc);
|
||||
}
|
||||
const pkgName =
|
||||
pkgDir.startsWith('@') ?
|
||||
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');
|
||||
} else {
|
||||
// see if we are in a dist folder.
|
||||
const d = __dirname.lastIndexOf(DIST);
|
||||
if (d !== -1) {
|
||||
return (0, node_path_1.resolve)(
|
||||
__dirname.substring(0, d),
|
||||
'package.json'
|
||||
);
|
||||
} else {
|
||||
return (0, node_path_1.resolve)(__dirname, pathFromSrc);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.findPackageJson = findPackageJson;
|
||||
/**
|
||||
@ -129,6 +136,12 @@ exports.findPackageJson = findPackageJson;
|
||||
* console.log(`Hello from ${pj.name}@${pj.version}`)
|
||||
* ```
|
||||
*/
|
||||
const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse((0, node_fs_1.readFileSync)((0, exports.findPackageJson)(from, pathFromSrc), 'utf8'));
|
||||
const loadPackageJson = (from, pathFromSrc = '../package.json') =>
|
||||
JSON.parse(
|
||||
(0, node_fs_1.readFileSync)(
|
||||
(0, exports.findPackageJson)(from, pathFromSrc),
|
||||
'utf8'
|
||||
)
|
||||
);
|
||||
exports.loadPackageJson = loadPackageJson;
|
||||
//# sourceMappingURL=index.js.map
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
12
node_modules/package-json-from-dist/dist/esm/index.d.ts
generated
vendored
12
node_modules/package-json-from-dist/dist/esm/index.d.ts
generated
vendored
@ -41,7 +41,10 @@
|
||||
* console.log(`package.json found at ${pj}`)
|
||||
* ```
|
||||
*/
|
||||
export declare const findPackageJson: (from: string | URL, pathFromSrc?: string) => string;
|
||||
export declare const findPackageJson: (
|
||||
from: string | URL,
|
||||
pathFromSrc?: string
|
||||
) => string;
|
||||
/**
|
||||
* Load the package.json file, either from a TypeScript file somewhere not
|
||||
* in a 'dist' folder, or a built and/or installed 'dist' folder.
|
||||
@ -85,5 +88,8 @@ export declare const findPackageJson: (from: string | URL, pathFromSrc?: string)
|
||||
* console.log(`Hello from ${pj.name}@${pj.version}`)
|
||||
* ```
|
||||
*/
|
||||
export declare const loadPackageJson: (from: string | URL, pathFromSrc?: string) => any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
export declare const loadPackageJson: (
|
||||
from: string | URL,
|
||||
pathFromSrc?: string
|
||||
) => any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
|
69
node_modules/package-json-from-dist/dist/esm/index.js
generated
vendored
69
node_modules/package-json-from-dist/dist/esm/index.js
generated
vendored
@ -49,38 +49,42 @@ const DIST = `${sep}dist${sep}`;
|
||||
* ```
|
||||
*/
|
||||
export const findPackageJson = (from, pathFromSrc = '../package.json') => {
|
||||
const f = typeof from === 'object' || from.startsWith('file://') ?
|
||||
fileURLToPath(from)
|
||||
: from;
|
||||
const __dirname = dirname(f);
|
||||
const nms = __dirname.lastIndexOf(NM);
|
||||
if (nms !== -1) {
|
||||
// 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, 2).join(sep)
|
||||
: String(pkgDir.split(sep)[0]);
|
||||
return resolve(nm, pkgName, 'package.json');
|
||||
const f =
|
||||
typeof from === 'object' || from.startsWith('file://') ?
|
||||
fileURLToPath(from)
|
||||
: from;
|
||||
const __dirname = dirname(f);
|
||||
const nms = __dirname.lastIndexOf(NM);
|
||||
if (nms !== -1) {
|
||||
// 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'
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// see if we are in a dist folder.
|
||||
const d = __dirname.lastIndexOf(DIST);
|
||||
if (d !== -1) {
|
||||
return resolve(__dirname.substring(0, d), 'package.json');
|
||||
}
|
||||
else {
|
||||
return resolve(__dirname, pathFromSrc);
|
||||
}
|
||||
const pkgName =
|
||||
pkgDir.startsWith('@') ?
|
||||
pkgDir.split(sep, 2).join(sep)
|
||||
: String(pkgDir.split(sep)[0]);
|
||||
return resolve(nm, pkgName, 'package.json');
|
||||
} else {
|
||||
// see if we are in a dist folder.
|
||||
const d = __dirname.lastIndexOf(DIST);
|
||||
if (d !== -1) {
|
||||
return resolve(__dirname.substring(0, d), 'package.json');
|
||||
} else {
|
||||
return resolve(__dirname, pathFromSrc);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Load the package.json file, either from a TypeScript file somewhere not
|
||||
@ -125,5 +129,6 @@ export const findPackageJson = (from, pathFromSrc = '../package.json') => {
|
||||
* console.log(`Hello from ${pj.name}@${pj.version}`)
|
||||
* ```
|
||||
*/
|
||||
export const loadPackageJson = (from, pathFromSrc = '../package.json') => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), 'utf8'));
|
||||
//# sourceMappingURL=index.js.map
|
||||
export const loadPackageJson = (from, pathFromSrc = '../package.json') =>
|
||||
JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), 'utf8'));
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
Reference in New Issue
Block a user