@itwin/build-tools 4.0.0-dev.15 → 4.0.0-dev.18

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": "4.0.0-dev.15",
3
+ "version": "4.0.0-dev.18",
4
4
  "description": "Bentley build tools",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,8 +37,8 @@
37
37
  "yargs": "^17.4.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@itwin/eslint-plugin": "4.0.0-dev.15",
41
- "@types/node": "18.11.5",
40
+ "@itwin/eslint-plugin": "4.0.0-dev.18",
41
+ "@types/node": "^18.11.5",
42
42
  "eslint": "^7.11.0"
43
43
  },
44
44
  "eslintConfig": {
@@ -8,24 +8,19 @@ const path = require("path");
8
8
 
9
9
  // We cannot guarantee the folder structure of a project
10
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
- }
11
+ const rootPackageJson = process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER
12
+ ? path.join(process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER, "package.json")
13
+ : "../../../../package.json"
19
14
 
20
- const rootPackageJson = require(rootPackageJsonPath);
15
+ // Check if path to root package.json is valid.
16
+ const rootPackageJsonPath = require.resolve(rootPackageJson);
21
17
 
22
18
  // Appends the directory of the package root to the Typedoc JSON output
23
19
  function addSourceDir(file, directory) {
24
20
  if (FS.existsSync(file) && FS.statSync(file).isFile()) {
25
21
  const contents = FS.readFileSync(file, "utf-8");
26
- const packageRoot = directory.substring(
27
- directory.indexOf(rootPackageJson.name) + rootPackageJson.name.length + 1
28
- );
22
+ const pathToRootFolder = path.dirname(rootPackageJsonPath);
23
+ const packageRoot = directory.substring(pathToRootFolder.length + 1);
29
24
  const jsonContents = JSON.parse(contents);
30
25
  jsonContents["packageRoot"] = packageRoot.endsWith("src")
31
26
  ? packageRoot