@travetto/manifest 5.0.6 → 5.0.8
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/README.md +1 -1
- package/package.json +1 -1
- package/src/context.ts +3 -3
- package/src/package.ts +13 -1
package/README.md
CHANGED
|
@@ -87,9 +87,9 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
87
87
|
"defaultEnv": "local"
|
|
88
88
|
},
|
|
89
89
|
"build": {
|
|
90
|
-
"compilerFolder": ".trv/compiler",
|
|
91
90
|
"compilerUrl": "http://127.0.0.1:26803",
|
|
92
91
|
"compilerModuleFolder": "module/compiler",
|
|
92
|
+
"compilerFolder": ".trv/compiler",
|
|
93
93
|
"outputFolder": ".trv/output",
|
|
94
94
|
"toolFolder": ".trv/tool",
|
|
95
95
|
"typesFolder": ".trv/types"
|
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -39,13 +39,13 @@ function findPackage(base: string, pred: (_p?: Pkg) => boolean): Pkg {
|
|
|
39
39
|
/**
|
|
40
40
|
* Gets build context
|
|
41
41
|
*/
|
|
42
|
-
export function getManifestContext(root: string
|
|
42
|
+
export function getManifestContext(root: string = process.cwd()): ManifestContext {
|
|
43
43
|
const workspace = findPackage(root, pkg => !!pkg?.workspaces || !!pkg?.travetto?.build?.isolated);
|
|
44
44
|
const build = workspace.travetto?.build ?? {};
|
|
45
45
|
const resolve = createRequire(path.resolve(workspace.path, 'node_modules')).resolve.bind(null);
|
|
46
46
|
const wsPrefix = `${workspace.path}/`;
|
|
47
|
-
const modPkg =
|
|
48
|
-
readPackage(resolve(`${
|
|
47
|
+
const modPkg = (!!workspace.workspaces && process.env.TRV_MODULE) ?
|
|
48
|
+
readPackage(resolve(`${process.env.TRV_MODULE}/package.json`)) :
|
|
49
49
|
findPackage(root, pkg => !!pkg) ?? workspace;
|
|
50
50
|
|
|
51
51
|
return {
|
package/src/package.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
3
4
|
|
|
4
5
|
import { path } from './path';
|
|
5
6
|
import { ManifestFileUtil } from './file';
|
|
@@ -52,7 +53,18 @@ export class PackageUtil {
|
|
|
52
53
|
try {
|
|
53
54
|
const resolved = this.resolveImport(name, root);
|
|
54
55
|
return path.join(resolved.split(name)[0], name);
|
|
55
|
-
} catch {
|
|
56
|
+
} catch { // When import lookup fails
|
|
57
|
+
let folder = root ?? process.cwd();
|
|
58
|
+
let prev = '';
|
|
59
|
+
while (folder !== prev) {
|
|
60
|
+
const pkg = path.resolve(folder, 'node_modules', name, 'package.json');
|
|
61
|
+
if (existsSync(pkg)) {
|
|
62
|
+
return pkg;
|
|
63
|
+
}
|
|
64
|
+
prev = folder;
|
|
65
|
+
folder = path.dirname(folder);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
56
68
|
}
|
|
57
69
|
throw new Error(`Unable to resolve: ${name}`);
|
|
58
70
|
}
|