File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
1
## TypeScript original
2
2
3
- Requires ` ts-node ` , usually installed from npm
3
+ Prior to NodeJS v22.6.0:
4
+ Install ` ts-node ` , usually installed from npm
4
5
5
6
` sudo npm install -g ts-node typescript `
7
+
8
+ ---
9
+
10
+ If you have NodeJS v22.6.0+:
11
+
12
+ ``` lua
13
+ require ' sniprun' .setup ({
14
+ interpreter_options = {
15
+ TypeScript_original = {
16
+ interpreter = ' node'
17
+ }
18
+ }
19
+ }
20
+ })
21
+ ```
22
+
23
+ [ ^ 1 ] : ` ts-node ` and ` typescript ` packages are no longer needed for newer NodeJS versions
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ pub struct TypeScript_original {
7
7
data : DataHolder ,
8
8
code : String ,
9
9
main_file_path : String ,
10
+
11
+ //specific to Typescript
12
+ interpreter : String ,
10
13
}
11
14
12
15
impl ReplLikeInterpreter for TypeScript_original { }
@@ -23,11 +26,17 @@ impl Interpreter for TypeScript_original {
23
26
24
27
//pre-create string pointing to main file's and binary's path
25
28
let mfp = lwd + "/main.ts" ;
29
+
30
+ let interpreter = match TypeScript_original :: get_interpreter_option ( & data, "interpreter" ) {
31
+ Some ( user_interpreter) => user_interpreter. to_string ( ) . replace ( "\" " , "" ) ,
32
+ None => "ts-node" . to_string ( )
33
+ } ;
26
34
Box :: new ( TypeScript_original {
27
35
data,
28
36
support_level,
29
37
code : String :: new ( ) ,
30
38
main_file_path : mfp,
39
+ interpreter
31
40
} )
32
41
}
33
42
@@ -114,7 +123,7 @@ impl Interpreter for TypeScript_original {
114
123
115
124
fn execute ( & mut self ) -> Result < String , SniprunError > {
116
125
//run th binary and get the std output (or stderr)
117
- let interpreter = TypeScript_original :: get_interpreter_or ( & self . data , "ts-node" ) ;
126
+ let interpreter = TypeScript_original :: get_interpreter_or ( & self . data , & self . interpreter ) ;
118
127
let output = Command :: new ( interpreter. split_whitespace ( ) . next ( ) . unwrap ( ) )
119
128
. args ( interpreter. split_whitespace ( ) . skip ( 1 ) )
120
129
. arg ( & self . main_file_path )
You can’t perform that action at this time.
0 commit comments