File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 14
14
*/
15
15
16
16
const path = require ( "path" ) ;
17
-
18
- const ts = require ( "typescript" ) ;
19
-
20
17
const cwd = process . cwd ( ) ;
21
18
22
19
// This is the calling module, which will be the node repl context.
23
- const main = module . parent ;
20
+ const main = require . main || module . parent ;
24
21
25
22
// We need to know which package name to monkey patch
26
23
const { name : hostPackageName } = main . require ( "./package.json" ) ;
27
24
25
+ // We need to use whatever version of TypeScript the calling package uses to inspect syntax nodes, because
26
+ // that is what the ts-node invocation will use, and we need to agree with it on syntax brands.
27
+ const ts = hostPackageName === "@azure/dev-tool"
28
+ ? require ( path . join ( cwd , "node_modules" , "typescript" ) )
29
+ : main . require ( "typescript" ) ;
30
+
28
31
// If we're bootstrapping a dev-tool command, we need to patch the package from
29
32
// CWD instead. This will still end up being dev-tool if we end up in a
30
33
// self-hosting situation where dev-tool calls itself from its own scripts.
You can’t perform that action at this time.
0 commit comments