@itwin/build-tools 3.4.0-dev.48 → 3.4.0-dev.55
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@itwin/build-tools",
|
3
|
-
"version": "3.4.0-dev.
|
3
|
+
"version": "3.4.0-dev.55",
|
4
4
|
"description": "Bentley build tools",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"yargs": "^17.4.0"
|
39
39
|
},
|
40
40
|
"devDependencies": {
|
41
|
-
"@itwin/eslint-plugin": "3.4.0-dev.
|
41
|
+
"@itwin/eslint-plugin": "3.4.0-dev.55",
|
42
42
|
"@types/node": "16.11.59",
|
43
43
|
"eslint": "^7.11.0"
|
44
44
|
},
|
@@ -3,20 +3,37 @@
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
5
5
|
|
6
|
-
const FS = require(
|
7
|
-
const
|
6
|
+
const FS = require("fs-extra");
|
7
|
+
const path = require("path");
|
8
|
+
|
9
|
+
// We cannot guarantee the folder structure of a project
|
10
|
+
// so find the project root using rush env variable if available.
|
11
|
+
if (process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER) {
|
12
|
+
rootPackageJsonPath = path.resolve(
|
13
|
+
process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER,
|
14
|
+
"package.json"
|
15
|
+
);
|
16
|
+
} else {
|
17
|
+
rootPackageJsonPath = path.resolve("../../../../package.json");
|
18
|
+
}
|
19
|
+
|
20
|
+
const rootPackageJson = require(rootPackageJsonPath);
|
8
21
|
|
9
22
|
// Appends the directory of the package root to the Typedoc JSON output
|
10
23
|
function addSourceDir(file, directory) {
|
11
24
|
if (FS.existsSync(file) && FS.statSync(file).isFile()) {
|
12
|
-
const contents = FS.readFileSync(file,
|
13
|
-
|
14
|
-
|
15
|
-
|
25
|
+
const contents = FS.readFileSync(file, "utf-8");
|
26
|
+
const packageRoot = directory.substring(
|
27
|
+
directory.indexOf(rootPackageJson.name) + rootPackageJson.name.length + 1
|
28
|
+
);
|
29
|
+
const jsonContents = JSON.parse(contents);
|
30
|
+
jsonContents["packageRoot"] = packageRoot.endsWith("src")
|
31
|
+
? packageRoot
|
32
|
+
: `${packageRoot}\\${"src"}`;
|
16
33
|
FS.writeFileSync(file, Buffer.from(JSON.stringify(jsonContents, null, 2)));
|
17
34
|
}
|
18
35
|
}
|
19
36
|
|
20
37
|
module.exports = {
|
21
|
-
addSourceDir
|
38
|
+
addSourceDir,
|
22
39
|
};
|