1
- require " tmpdir"
2
- require " tempfile"
3
- require " typescript-src"
4
- require " typescript-node/version"
5
- require " typescript-node/compile_result"
6
- require " open3"
1
+ require ' tmpdir'
2
+ require ' tempfile'
3
+ require ' typescript-src'
4
+ require ' typescript-node/version'
5
+ require ' typescript-node/compile_result'
6
+ require ' open3'
7
7
8
8
module TypeScript
9
9
module Node
@@ -23,15 +23,15 @@ def tsc(*args)
23
23
# @return [TypeScript::Node::CompileResult] compile result
24
24
def compile_file ( source_file , *tsc_options )
25
25
Dir . mktmpdir do |output_dir |
26
- output_file = File . join ( output_dir , " out.js" )
26
+ output_file = File . join ( output_dir , ' out.js' )
27
27
stdout , stderr , exit_status = tsc ( *tsc_options , '--out' , output_file , source_file )
28
28
29
29
output_js = File . exists? ( output_file ) ? File . read ( output_file ) : nil
30
30
CompileResult . new (
31
- output_js ,
32
- exit_status ,
33
- stdout ,
34
- stderr ,
31
+ output_js ,
32
+ exit_status ,
33
+ stdout ,
34
+ stderr ,
35
35
)
36
36
end
37
37
end
@@ -40,15 +40,15 @@ def compile_file(source_file, *tsc_options)
40
40
# @param [String] source TypeScript to be compiled
41
41
# @return [String] Resulted JavaScript
42
42
def compile ( source , *tsc_options )
43
- js_file = Tempfile . new ( [ " typescript-node" , " .ts" ] )
43
+ js_file = Tempfile . new ( %w( typescript-node .ts ) )
44
44
begin
45
45
js_file . write ( source )
46
46
js_file . close
47
47
result = compile_file ( js_file . path , *tsc_options )
48
48
if result . success?
49
49
result . js
50
50
else
51
- raise result . stderr
51
+ raise result . stderr + result . stdout
52
52
end
53
53
ensure
54
54
js_file . unlink
@@ -58,11 +58,11 @@ def compile(source, *tsc_options)
58
58
# node command
59
59
# TS_NODE environmental variable is used when it is set.
60
60
def node
61
- ENV [ " TS_NODE" ] || " node"
61
+ ENV [ ' TS_NODE' ] || ' node'
62
62
end
63
63
64
64
def locate_executable ( cmd )
65
- if RbConfig ::CONFIG [ " host_os" ] =~ /mswin|mingw/ && File . extname ( cmd ) == ""
65
+ if RbConfig ::CONFIG [ ' host_os' ] =~ /mswin|mingw/ && File . extname ( cmd ) == ""
66
66
cmd << ".exe"
67
67
end
68
68
@@ -79,12 +79,11 @@ def locate_executable(cmd)
79
79
80
80
def check_node
81
81
unless locate_executable ( node )
82
- raise "typescript-node requires node command, but it's not found. Please install it. " +
83
- "Set TS_NODE environmental variable If you want to use node command in non-standard path."
82
+ raise "typescript-node requires node command, but it's not found. Please install it. Set TS_NODE environmental variable If you want to use node command in non-standard path."
84
83
end
85
84
end
86
85
end
87
86
end
88
87
end
89
88
90
- TypeScript ::Node . check_node
89
+ TypeScript ::Node . check_node
0 commit comments