|
8 | 8 | */
|
9 | 9 | import('fs').then(({ existsSync, readFileSync }) => {
|
10 | 10 | import('tsconfig-paths').then(({ loadConfig, register }) => {
|
11 |
| - if ( |
12 |
| - process.env.TARGET_ACTION_PATH && |
13 |
| - process.env.TARGET_ACTION_PATH !== '' |
14 |
| - ) { |
15 |
| - // Check if the action has a `tsconfig.json` file. |
16 |
| - if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) { |
17 |
| - // Load the `tsconfig.json` from the action directory. |
18 |
| - const actionTsConfig = JSON.parse( |
19 |
| - readFileSync( |
20 |
| - `${process.env.TARGET_ACTION_PATH}/tsconfig.json`, |
21 |
| - 'utf-8' |
| 11 | + import('comment-json').then(({ parse }) => { |
| 12 | + if ( |
| 13 | + process.env.TARGET_ACTION_PATH && |
| 14 | + process.env.TARGET_ACTION_PATH !== '' |
| 15 | + ) { |
| 16 | + // Check if the action has a `tsconfig.json` file. |
| 17 | + if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) { |
| 18 | + // Load the `tsconfig.json` from the action directory. |
| 19 | + const actionTsConfig = parse( |
| 20 | + readFileSync( |
| 21 | + `${process.env.TARGET_ACTION_PATH}/tsconfig.json`, |
| 22 | + 'utf-8' |
| 23 | + ) |
22 | 24 | )
|
23 |
| - ) |
24 | 25 |
|
25 |
| - // Load the current `tsconfig.json` from the root of this directory. |
26 |
| - loadConfig(__dirname) |
| 26 | + // Load the current `tsconfig.json` from the root of this directory. |
| 27 | + loadConfig(__dirname) |
27 | 28 |
|
28 |
| - // Get the paths from the action's `tsconfig.json`, if any. |
29 |
| - const paths = actionTsConfig.compilerOptions.paths ?? {} |
| 29 | + // Get the paths from the action's `tsconfig.json`, if any. |
| 30 | + // @ts-expect-error The `compilerOptions` property is not typed. |
| 31 | + const paths = actionTsConfig.compilerOptions?.paths ?? {} |
30 | 32 |
|
31 |
| - // Add any path mappings from the imported action. Replace the base URL with |
32 |
| - // the target action path. |
33 |
| - // @todo Should this take into account the previous `baseUrl` value? |
34 |
| - register({ |
35 |
| - baseUrl: process.env.TARGET_ACTION_PATH, |
36 |
| - paths, |
37 |
| - addMatchAll: true |
38 |
| - }) |
| 33 | + // Add any path mappings from the imported action. Replace the base URL with |
| 34 | + // the target action path. |
| 35 | + // @todo Should this take into account the previous `baseUrl` value? |
| 36 | + register({ |
| 37 | + baseUrl: process.env.TARGET_ACTION_PATH, |
| 38 | + paths, |
| 39 | + addMatchAll: true |
| 40 | + }) |
| 41 | + } |
39 | 42 | }
|
40 |
| - } |
| 43 | + }) |
41 | 44 | })
|
42 | 45 | })
|
0 commit comments