|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 |
|
| 9 | +import tsNode from 'ts-node'; |
| 10 | + |
9 | 11 | import {dirname, join} from 'path'; |
10 | 12 | import {Assertions, MultipleAssertions} from './assertion-typings'; |
11 | 13 |
|
@@ -36,9 +38,6 @@ export interface GithubConfig { |
36 | 38 | */ |
37 | 39 | const CONFIG_FILE_PATH = '.ng-dev/config'; |
38 | 40 |
|
39 | | -/** The configuration for ng-dev. */ |
40 | | -let cachedConfig: {} | null = null; |
41 | | - |
42 | 41 | /** |
43 | 42 | * The filename expected for local user config, without the file extension to allow a typescript, |
44 | 43 | * javascript or json file to be used. |
@@ -147,23 +146,15 @@ export function assertValidGithubConfig<T>( |
147 | 146 | * configuration file cannot be read. |
148 | 147 | */ |
149 | 148 | function readConfigFile(configPath: string, returnEmptyObjectOnError = false): {} { |
150 | | - // If the `.ts` extension has not been set up already, and a TypeScript based |
151 | | - // version of the given configuration seems to exist, set up `ts-node` if available. |
152 | | - if ( |
153 | | - require.extensions['.ts'] === undefined && |
154 | | - existsSync(`${configPath}.ts`) && |
155 | | - isTsNodeAvailable() |
156 | | - ) { |
157 | | - // Ensure the module target is set to `commonjs`. This is necessary because the |
158 | | - // dev-infra tool runs in NodeJS which does not support ES modules by default. |
159 | | - // Additionally, set the `dir` option to the directory that contains the configuration |
160 | | - // file. This allows for custom compiler options (such as `--strict`). |
161 | | - require('ts-node').register({ |
162 | | - dir: dirname(configPath), |
163 | | - transpileOnly: true, |
164 | | - compilerOptions: {module: 'commonjs'}, |
165 | | - }); |
166 | | - } |
| 149 | + // Ensure the module target is set to `commonjs`. This is necessary because the |
| 150 | + // dev-infra tool runs in NodeJS which does not support ES modules by default. |
| 151 | + // Additionally, set the `dir` option to the directory that contains the configuration |
| 152 | + // file. This allows for custom compiler options (such as `--strict`). |
| 153 | + tsNode.register({ |
| 154 | + dir: dirname(configPath), |
| 155 | + transpileOnly: true, |
| 156 | + compilerOptions: {module: 'commonjs'}, |
| 157 | + }); |
167 | 158 |
|
168 | 159 | try { |
169 | 160 | return require(configPath); |
|
0 commit comments