@wyw-in-js/shared 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/findPackageJSON.js +29 -0
- package/esm/findPackageJSON.js.map +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/lib/findPackageJSON.js +38 -0
- package/lib/findPackageJSON.js.map +1 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -1
- package/package.json +9 -7
- package/types/findPackageJSON.d.ts +1 -0
- package/types/findPackageJSON.js +59 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +3 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dirname, isAbsolute } from 'path';
|
|
2
|
+
import * as process from 'process';
|
|
3
|
+
import findUp from 'find-up';
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
export function findPackageJSON(pkgName, filename) {
|
|
6
|
+
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
7
|
+
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
8
|
+
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
9
|
+
try {
|
|
10
|
+
const pkgPath = pkgName === '.' && filename && isAbsolute(filename) ? filename : require.resolve(pkgName, filename ? {
|
|
11
|
+
paths: [dirname(filename)]
|
|
12
|
+
} : {});
|
|
13
|
+
if (!cache.has(pkgPath)) {
|
|
14
|
+
cache.set(pkgPath, findUp.sync('package.json', {
|
|
15
|
+
cwd: pkgPath
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
return cache.get(pkgPath);
|
|
19
|
+
} catch (er) {
|
|
20
|
+
if (typeof er === 'object' && er !== null && er.code === 'MODULE_NOT_FOUND') {
|
|
21
|
+
if (skipPathsOptions && filename) {
|
|
22
|
+
return findPackageJSON(pkgName, null);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
throw er;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=findPackageJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPackageJSON.js","names":["dirname","isAbsolute","process","findUp","cache","Map","findPackageJSON","pkgName","filename","isJest","Boolean","env","JEST_WORKER_ID","skipPathsOptions","startsWith","pkgPath","require","resolve","paths","has","set","sync","cwd","get","er","code","undefined"],"sources":["../src/findPackageJSON.ts"],"sourcesContent":["import { dirname, isAbsolute } from 'path';\nimport * as process from 'process';\n\nimport findUp from 'find-up';\n\nconst cache = new Map<string, string | undefined>();\n\nexport function findPackageJSON(\n pkgName: string,\n filename: string | null | undefined\n) {\n // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined\n const isJest = Boolean(process.env.JEST_WORKER_ID);\n const skipPathsOptions = isJest && !pkgName.startsWith('.');\n\n try {\n const pkgPath =\n pkgName === '.' && filename && isAbsolute(filename)\n ? filename\n : require.resolve(\n pkgName,\n filename ? { paths: [dirname(filename)] } : {}\n );\n if (!cache.has(pkgPath)) {\n cache.set(pkgPath, findUp.sync('package.json', { cwd: pkgPath }));\n }\n\n return cache.get(pkgPath);\n } catch (er: unknown) {\n if (\n typeof er === 'object' &&\n er !== null &&\n (er as { code?: unknown }).code === 'MODULE_NOT_FOUND'\n ) {\n if (skipPathsOptions && filename) {\n return findPackageJSON(pkgName, null);\n }\n\n return undefined;\n }\n\n throw er;\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,UAAU,QAAQ,MAAM;AAC1C,OAAO,KAAKC,OAAO,MAAM,SAAS;AAElC,OAAOC,MAAM,MAAM,SAAS;AAE5B,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAA6B,CAAC;AAEnD,OAAO,SAASC,eAAeA,CAC7BC,OAAe,EACfC,QAAmC,EACnC;EACA;EACA,MAAMC,MAAM,GAAGC,OAAO,CAACR,OAAO,CAACS,GAAG,CAACC,cAAc,CAAC;EAClD,MAAMC,gBAAgB,GAAGJ,MAAM,IAAI,CAACF,OAAO,CAACO,UAAU,CAAC,GAAG,CAAC;EAE3D,IAAI;IACF,MAAMC,OAAO,GACXR,OAAO,KAAK,GAAG,IAAIC,QAAQ,IAAIP,UAAU,CAACO,QAAQ,CAAC,GAC/CA,QAAQ,GACRQ,OAAO,CAACC,OAAO,CACbV,OAAO,EACPC,QAAQ,GAAG;MAAEU,KAAK,EAAE,CAAClB,OAAO,CAACQ,QAAQ,CAAC;IAAE,CAAC,GAAG,CAAC,CAC/C,CAAC;IACP,IAAI,CAACJ,KAAK,CAACe,GAAG,CAACJ,OAAO,CAAC,EAAE;MACvBX,KAAK,CAACgB,GAAG,CAACL,OAAO,EAAEZ,MAAM,CAACkB,IAAI,CAAC,cAAc,EAAE;QAAEC,GAAG,EAAEP;MAAQ,CAAC,CAAC,CAAC;IACnE;IAEA,OAAOX,KAAK,CAACmB,GAAG,CAACR,OAAO,CAAC;EAC3B,CAAC,CAAC,OAAOS,EAAW,EAAE;IACpB,IACE,OAAOA,EAAE,KAAK,QAAQ,IACtBA,EAAE,KAAK,IAAI,IACVA,EAAE,CAAwBC,IAAI,KAAK,kBAAkB,EACtD;MACA,IAAIZ,gBAAgB,IAAIL,QAAQ,EAAE;QAChC,OAAOF,eAAe,CAACC,OAAO,EAAE,IAAI,CAAC;MACvC;MAEA,OAAOmB,SAAS;IAClB;IAEA,MAAMF,EAAE;EACV;AACF"}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { Debugger } from 'debug';
|
|
2
2
|
export { asyncResolveFallback, syncResolve } from './asyncResolveFallback';
|
|
3
3
|
export { hasEvalMeta } from './hasEvalMeta';
|
|
4
|
+
export { findPackageJSON } from './findPackageJSON';
|
|
4
5
|
export { isBoxedPrimitive } from './isBoxedPrimitive';
|
|
6
|
+
export { IVariableContext } from './IVariableContext';
|
|
5
7
|
export { enableDebug, logger } from './logger';
|
|
6
8
|
export { isFeatureEnabled } from './options/isFeatureEnabled';
|
|
7
9
|
export { slugify } from './slugify';
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Debugger","asyncResolveFallback","syncResolve","hasEvalMeta","isBoxedPrimitive","enableDebug","logger","isFeatureEnabled","slugify","ValueType"],"sources":["../src/index.ts"],"sourcesContent":["export { Debugger } from 'debug';\n\nexport { asyncResolveFallback, syncResolve } from './asyncResolveFallback';\nexport { hasEvalMeta } from './hasEvalMeta';\nexport { isBoxedPrimitive } from './isBoxedPrimitive';\nexport { enableDebug, logger } from './logger';\nexport { isFeatureEnabled } from './options/isFeatureEnabled';\nexport { slugify } from './slugify';\nexport { ValueType } from './types';\n\nexport type {\n ClassNameSlugVars,\n ClassNameFn,\n StrictOptions,\n EvalRule,\n Evaluator,\n FeatureFlag,\n EvaluatorConfig,\n FeatureFlags,\n VariableNameFn,\n} from './options/types';\nexport type {\n Artifact,\n BuildCodeFrameErrorFn,\n ConstValue,\n ExpressionValue,\n FunctionValue,\n ICSSRule,\n LazyValue,\n Location,\n Replacement,\n Replacements,\n Rules,\n WYWEvalMeta,\n} from './types';\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAEhC,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,wBAAwB;AAC1E,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,EAAEC,MAAM,QAAQ,UAAU;AAC9C,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,SAAS,QAAQ,SAAS"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Debugger","asyncResolveFallback","syncResolve","hasEvalMeta","findPackageJSON","isBoxedPrimitive","IVariableContext","enableDebug","logger","isFeatureEnabled","slugify","ValueType"],"sources":["../src/index.ts"],"sourcesContent":["export { Debugger } from 'debug';\n\nexport { asyncResolveFallback, syncResolve } from './asyncResolveFallback';\nexport { hasEvalMeta } from './hasEvalMeta';\nexport { findPackageJSON } from './findPackageJSON';\nexport { isBoxedPrimitive } from './isBoxedPrimitive';\nexport { IVariableContext } from './IVariableContext';\nexport { enableDebug, logger } from './logger';\nexport { isFeatureEnabled } from './options/isFeatureEnabled';\nexport { slugify } from './slugify';\nexport { ValueType } from './types';\n\nexport type {\n ClassNameSlugVars,\n ClassNameFn,\n StrictOptions,\n EvalRule,\n Evaluator,\n FeatureFlag,\n EvaluatorConfig,\n FeatureFlags,\n VariableNameFn,\n} from './options/types';\nexport type {\n Artifact,\n BuildCodeFrameErrorFn,\n ConstValue,\n ExpressionValue,\n FunctionValue,\n ICSSRule,\n LazyValue,\n Location,\n Replacement,\n Replacements,\n Rules,\n WYWEvalMeta,\n} from './types';\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAEhC,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,wBAAwB;AAC1E,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,EAAEC,MAAM,QAAQ,UAAU;AAC9C,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,SAAS,QAAQ,SAAS"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findPackageJSON = findPackageJSON;
|
|
7
|
+
var _path = require("path");
|
|
8
|
+
var process = _interopRequireWildcard(require("process"));
|
|
9
|
+
var _findUp = _interopRequireDefault(require("find-up"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const cache = new Map();
|
|
14
|
+
function findPackageJSON(pkgName, filename) {
|
|
15
|
+
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
16
|
+
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
17
|
+
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
18
|
+
try {
|
|
19
|
+
const pkgPath = pkgName === '.' && filename && (0, _path.isAbsolute)(filename) ? filename : require.resolve(pkgName, filename ? {
|
|
20
|
+
paths: [(0, _path.dirname)(filename)]
|
|
21
|
+
} : {});
|
|
22
|
+
if (!cache.has(pkgPath)) {
|
|
23
|
+
cache.set(pkgPath, _findUp.default.sync('package.json', {
|
|
24
|
+
cwd: pkgPath
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
return cache.get(pkgPath);
|
|
28
|
+
} catch (er) {
|
|
29
|
+
if (typeof er === 'object' && er !== null && er.code === 'MODULE_NOT_FOUND') {
|
|
30
|
+
if (skipPathsOptions && filename) {
|
|
31
|
+
return findPackageJSON(pkgName, null);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
throw er;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=findPackageJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPackageJSON.js","names":["_path","require","process","_interopRequireWildcard","_findUp","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","cache","Map","findPackageJSON","pkgName","filename","isJest","Boolean","env","JEST_WORKER_ID","skipPathsOptions","startsWith","pkgPath","isAbsolute","resolve","paths","dirname","findUp","sync","cwd","er","code","undefined"],"sources":["../src/findPackageJSON.ts"],"sourcesContent":["import { dirname, isAbsolute } from 'path';\nimport * as process from 'process';\n\nimport findUp from 'find-up';\n\nconst cache = new Map<string, string | undefined>();\n\nexport function findPackageJSON(\n pkgName: string,\n filename: string | null | undefined\n) {\n // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined\n const isJest = Boolean(process.env.JEST_WORKER_ID);\n const skipPathsOptions = isJest && !pkgName.startsWith('.');\n\n try {\n const pkgPath =\n pkgName === '.' && filename && isAbsolute(filename)\n ? filename\n : require.resolve(\n pkgName,\n filename ? { paths: [dirname(filename)] } : {}\n );\n if (!cache.has(pkgPath)) {\n cache.set(pkgPath, findUp.sync('package.json', { cwd: pkgPath }));\n }\n\n return cache.get(pkgPath);\n } catch (er: unknown) {\n if (\n typeof er === 'object' &&\n er !== null &&\n (er as { code?: unknown }).code === 'MODULE_NOT_FOUND'\n ) {\n if (skipPathsOptions && filename) {\n return findPackageJSON(pkgName, null);\n }\n\n return undefined;\n }\n\n throw er;\n }\n}\n"],"mappings":"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"}
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "Debugger", {
|
|
|
9
9
|
return _debug.Debugger;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "IVariableContext", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _IVariableContext.IVariableContext;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "ValueType", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -27,6 +33,12 @@ Object.defineProperty(exports, "enableDebug", {
|
|
|
27
33
|
return _logger.enableDebug;
|
|
28
34
|
}
|
|
29
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "findPackageJSON", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _findPackageJSON.findPackageJSON;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
30
42
|
Object.defineProperty(exports, "hasEvalMeta", {
|
|
31
43
|
enumerable: true,
|
|
32
44
|
get: function () {
|
|
@@ -66,7 +78,9 @@ Object.defineProperty(exports, "syncResolve", {
|
|
|
66
78
|
var _debug = require("debug");
|
|
67
79
|
var _asyncResolveFallback = require("./asyncResolveFallback");
|
|
68
80
|
var _hasEvalMeta = require("./hasEvalMeta");
|
|
81
|
+
var _findPackageJSON = require("./findPackageJSON");
|
|
69
82
|
var _isBoxedPrimitive = require("./isBoxedPrimitive");
|
|
83
|
+
var _IVariableContext = require("./IVariableContext");
|
|
70
84
|
var _logger = require("./logger");
|
|
71
85
|
var _isFeatureEnabled = require("./options/isFeatureEnabled");
|
|
72
86
|
var _slugify = require("./slugify");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_debug","require","_asyncResolveFallback","_hasEvalMeta","_isBoxedPrimitive","_logger","_isFeatureEnabled","_slugify","_types"],"sources":["../src/index.ts"],"sourcesContent":["export { Debugger } from 'debug';\n\nexport { asyncResolveFallback, syncResolve } from './asyncResolveFallback';\nexport { hasEvalMeta } from './hasEvalMeta';\nexport { isBoxedPrimitive } from './isBoxedPrimitive';\nexport { enableDebug, logger } from './logger';\nexport { isFeatureEnabled } from './options/isFeatureEnabled';\nexport { slugify } from './slugify';\nexport { ValueType } from './types';\n\nexport type {\n ClassNameSlugVars,\n ClassNameFn,\n StrictOptions,\n EvalRule,\n Evaluator,\n FeatureFlag,\n EvaluatorConfig,\n FeatureFlags,\n VariableNameFn,\n} from './options/types';\nexport type {\n Artifact,\n BuildCodeFrameErrorFn,\n ConstValue,\n ExpressionValue,\n FunctionValue,\n ICSSRule,\n LazyValue,\n Location,\n Replacement,\n Replacements,\n Rules,\n WYWEvalMeta,\n} from './types';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_debug","require","_asyncResolveFallback","_hasEvalMeta","_findPackageJSON","_isBoxedPrimitive","_IVariableContext","_logger","_isFeatureEnabled","_slugify","_types"],"sources":["../src/index.ts"],"sourcesContent":["export { Debugger } from 'debug';\n\nexport { asyncResolveFallback, syncResolve } from './asyncResolveFallback';\nexport { hasEvalMeta } from './hasEvalMeta';\nexport { findPackageJSON } from './findPackageJSON';\nexport { isBoxedPrimitive } from './isBoxedPrimitive';\nexport { IVariableContext } from './IVariableContext';\nexport { enableDebug, logger } from './logger';\nexport { isFeatureEnabled } from './options/isFeatureEnabled';\nexport { slugify } from './slugify';\nexport { ValueType } from './types';\n\nexport type {\n ClassNameSlugVars,\n ClassNameFn,\n StrictOptions,\n EvalRule,\n Evaluator,\n FeatureFlag,\n EvaluatorConfig,\n FeatureFlags,\n VariableNameFn,\n} from './options/types';\nexport type {\n Artifact,\n BuildCodeFrameErrorFn,\n ConstValue,\n ExpressionValue,\n FunctionValue,\n ICSSRule,\n LazyValue,\n Location,\n Replacement,\n Replacements,\n Rules,\n WYWEvalMeta,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyw-in-js/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"debug": "^4.3.4",
|
|
6
|
+
"find-up": "^5.0.0",
|
|
6
7
|
"minimatch": "^9.0.3"
|
|
7
8
|
},
|
|
8
9
|
"devDependencies": {
|
|
9
|
-
"@babel/types": "^7.23.
|
|
10
|
-
"@types/babel__core": "^7.20.
|
|
10
|
+
"@babel/types": "^7.23.5",
|
|
11
|
+
"@types/babel__core": "^7.20.5",
|
|
11
12
|
"@types/debug": "^4.1.9",
|
|
12
13
|
"@types/node": "^16.18.55",
|
|
13
14
|
"typescript": "^5.2.2",
|
|
14
|
-
"@wyw-in-js/babel-config": "0.
|
|
15
|
-
"@wyw-in-js/eslint-config": "0.
|
|
16
|
-
"@wyw-in-js/
|
|
15
|
+
"@wyw-in-js/babel-config": "0.2.0",
|
|
16
|
+
"@wyw-in-js/eslint-config": "0.2.0",
|
|
17
|
+
"@wyw-in-js/jest-preset": "0.2.0",
|
|
18
|
+
"@wyw-in-js/ts-config": "0.2.0"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|
|
19
21
|
"node": ">=16.0.0"
|
|
@@ -35,6 +37,6 @@
|
|
|
35
37
|
"build:lib": "cross-env NODE_ENV=legacy babel src --out-dir lib --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
|
|
36
38
|
"build:types": "tsc --project ./tsconfig.lib.json --baseUrl . --rootDir ./src",
|
|
37
39
|
"lint": "eslint --ext .js,.ts .",
|
|
38
|
-
"test": "jest --config ./jest.config.js
|
|
40
|
+
"test": "jest --config ./jest.config.js"
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findPackageJSON(pkgName: string, filename: string | null | undefined): string | undefined;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.findPackageJSON = void 0;
|
|
30
|
+
const path_1 = require("path");
|
|
31
|
+
const process = __importStar(require("process"));
|
|
32
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
33
|
+
const cache = new Map();
|
|
34
|
+
function findPackageJSON(pkgName, filename) {
|
|
35
|
+
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
36
|
+
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
37
|
+
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
38
|
+
try {
|
|
39
|
+
const pkgPath = pkgName === '.' && filename && (0, path_1.isAbsolute)(filename)
|
|
40
|
+
? filename
|
|
41
|
+
: require.resolve(pkgName, filename ? { paths: [(0, path_1.dirname)(filename)] } : {});
|
|
42
|
+
if (!cache.has(pkgPath)) {
|
|
43
|
+
cache.set(pkgPath, find_up_1.default.sync('package.json', { cwd: pkgPath }));
|
|
44
|
+
}
|
|
45
|
+
return cache.get(pkgPath);
|
|
46
|
+
}
|
|
47
|
+
catch (er) {
|
|
48
|
+
if (typeof er === 'object' &&
|
|
49
|
+
er !== null &&
|
|
50
|
+
er.code === 'MODULE_NOT_FOUND') {
|
|
51
|
+
if (skipPathsOptions && filename) {
|
|
52
|
+
return findPackageJSON(pkgName, null);
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
throw er;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.findPackageJSON = findPackageJSON;
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { Debugger } from 'debug';
|
|
2
2
|
export { asyncResolveFallback, syncResolve } from './asyncResolveFallback';
|
|
3
3
|
export { hasEvalMeta } from './hasEvalMeta';
|
|
4
|
+
export { findPackageJSON } from './findPackageJSON';
|
|
4
5
|
export { isBoxedPrimitive } from './isBoxedPrimitive';
|
|
6
|
+
export { IVariableContext } from './IVariableContext';
|
|
5
7
|
export { enableDebug, logger } from './logger';
|
|
6
8
|
export { isFeatureEnabled } from './options/isFeatureEnabled';
|
|
7
9
|
export { slugify } from './slugify';
|
package/types/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValueType = exports.slugify = exports.isFeatureEnabled = exports.logger = exports.enableDebug = exports.isBoxedPrimitive = exports.hasEvalMeta = exports.syncResolve = exports.asyncResolveFallback = void 0;
|
|
3
|
+
exports.ValueType = exports.slugify = exports.isFeatureEnabled = exports.logger = exports.enableDebug = exports.isBoxedPrimitive = exports.findPackageJSON = exports.hasEvalMeta = exports.syncResolve = exports.asyncResolveFallback = void 0;
|
|
4
4
|
var asyncResolveFallback_1 = require("./asyncResolveFallback");
|
|
5
5
|
Object.defineProperty(exports, "asyncResolveFallback", { enumerable: true, get: function () { return asyncResolveFallback_1.asyncResolveFallback; } });
|
|
6
6
|
Object.defineProperty(exports, "syncResolve", { enumerable: true, get: function () { return asyncResolveFallback_1.syncResolve; } });
|
|
7
7
|
var hasEvalMeta_1 = require("./hasEvalMeta");
|
|
8
8
|
Object.defineProperty(exports, "hasEvalMeta", { enumerable: true, get: function () { return hasEvalMeta_1.hasEvalMeta; } });
|
|
9
|
+
var findPackageJSON_1 = require("./findPackageJSON");
|
|
10
|
+
Object.defineProperty(exports, "findPackageJSON", { enumerable: true, get: function () { return findPackageJSON_1.findPackageJSON; } });
|
|
9
11
|
var isBoxedPrimitive_1 = require("./isBoxedPrimitive");
|
|
10
12
|
Object.defineProperty(exports, "isBoxedPrimitive", { enumerable: true, get: function () { return isBoxedPrimitive_1.isBoxedPrimitive; } });
|
|
11
13
|
var logger_1 = require("./logger");
|