@netlify/build-info 6.0.4 → 6.0.6
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/lib/context.js +12 -10
- package/lib/workspaces.js +1 -1
- package/package.json +3 -3
package/lib/context.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
2
3
|
import { cwd } from 'process';
|
|
4
|
+
import { findUp } from 'find-up';
|
|
3
5
|
import { readPackage } from 'read-pkg';
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param cwd The current working directory where it tries to find the package.json
|
|
7
|
-
* @returns A parsed object of the package.json
|
|
7
|
+
* Collects the root package.json if there is one.
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return await readPackage({ cwd, normalize: false });
|
|
9
|
+
const getRootPackageJson = async (projectDir, rootDir) => {
|
|
10
|
+
if (existsSync(join(rootDir, 'package.json'))) {
|
|
11
|
+
return await readPackage({ cwd: rootDir, normalize: false });
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const json = await findUp('package.json', { cwd: projectDir, stopAt: rootDir });
|
|
14
|
+
if (json) {
|
|
15
|
+
return await readPackage({ cwd: dirname(json), normalize: false });
|
|
15
16
|
}
|
|
17
|
+
return {};
|
|
16
18
|
};
|
|
17
19
|
export const getContext = async (config = {}) => {
|
|
18
20
|
const { projectDir = cwd(), rootDir = '' } = config;
|
|
@@ -27,7 +29,7 @@ export const getContext = async (config = {}) => {
|
|
|
27
29
|
// If rootDir equals projectDir we'll be getting the projectDir package.json
|
|
28
30
|
// Later on if we also need the projectDir package.json we can check for it
|
|
29
31
|
// and only perform one resolution
|
|
30
|
-
const rootPackageJson = await
|
|
32
|
+
const rootPackageJson = await getRootPackageJson(absoluteProjectDir, validRootDir || absoluteProjectDir);
|
|
31
33
|
return {
|
|
32
34
|
projectDir: absoluteProjectDir,
|
|
33
35
|
rootDir: validRootDir,
|
package/lib/workspaces.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Build info utility",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Netlify Inc.",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@netlify/framework-info": "^9.5.
|
|
33
|
+
"@netlify/framework-info": "^9.5.2",
|
|
34
34
|
"@npmcli/map-workspaces": "^2.0.0",
|
|
35
35
|
"find-up": "^6.3.0",
|
|
36
36
|
"read-pkg": "^7.1.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": "^14.16.0 || >=16.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "c7e107e79b77f3037ca6d10aceadfa208af5ace8"
|
|
56
56
|
}
|