Skip to content

Commit cc4c3f1

Browse files
committed
Merge pull request #6 from typescript-ruby/updating_ts_version
Added stdout to output when Typescript compilation error occurs
2 parents b88c4ea + 9d57a82 commit cc4c3f1

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.4.1 2015-07-06 22:36:25+0300
2+
3+
* Added stdout to output when Typescript compilation error occurs
4+
15
## v1.1.1 2015-04-19 15:40:00+0900
26

37
* Use capture3 instead of popen3 to handle tsc I/O.

lib/typescript-node.rb

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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'
77

88
module TypeScript
99
module Node
@@ -23,15 +23,15 @@ def tsc(*args)
2323
# @return [TypeScript::Node::CompileResult] compile result
2424
def compile_file(source_file, *tsc_options)
2525
Dir.mktmpdir do |output_dir|
26-
output_file = File.join(output_dir, "out.js")
26+
output_file = File.join(output_dir, 'out.js')
2727
stdout, stderr, exit_status = tsc(*tsc_options, '--out', output_file, source_file)
2828

2929
output_js = File.exists?(output_file) ? File.read(output_file) : nil
3030
CompileResult.new(
31-
output_js,
32-
exit_status,
33-
stdout,
34-
stderr,
31+
output_js,
32+
exit_status,
33+
stdout,
34+
stderr,
3535
)
3636
end
3737
end
@@ -40,15 +40,15 @@ def compile_file(source_file, *tsc_options)
4040
# @param [String] source TypeScript to be compiled
4141
# @return [String] Resulted JavaScript
4242
def compile(source, *tsc_options)
43-
js_file = Tempfile.new(["typescript-node", ".ts"])
43+
js_file = Tempfile.new(%w(typescript-node .ts))
4444
begin
4545
js_file.write(source)
4646
js_file.close
4747
result = compile_file(js_file.path, *tsc_options)
4848
if result.success?
4949
result.js
5050
else
51-
raise result.stderr
51+
raise result.stderr + result.stdout
5252
end
5353
ensure
5454
js_file.unlink
@@ -58,11 +58,11 @@ def compile(source, *tsc_options)
5858
# node command
5959
# TS_NODE environmental variable is used when it is set.
6060
def node
61-
ENV["TS_NODE"] || "node"
61+
ENV['TS_NODE'] || 'node'
6262
end
6363

6464
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) == ""
6666
cmd << ".exe"
6767
end
6868

@@ -79,12 +79,11 @@ def locate_executable(cmd)
7979

8080
def check_node
8181
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."
8483
end
8584
end
8685
end
8786
end
8887
end
8988

90-
TypeScript::Node.check_node
89+
TypeScript::Node.check_node

lib/typescript-node/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module TypeScript
22
module Node
3-
VERSION = '1.1.1'
3+
VERSION = '1.4.1'
44
end
55
end

test/test_typescript-node.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def test_compile_file_in_failure
2828

2929
assert { subject.exit_status != 0 }
3030
assert { !subject.success? }
31-
assert { subject.stdout == '' }
32-
assert { subject.stderr != '' }
31+
assert { subject.stdout != '' || subject.stderr != '' }
3332
end
3433

3534
def test_compile_file_with_es5

typescript-node.gemspec

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
require File.expand_path('../lib/typescript-node/version', __FILE__)
33

44
Gem::Specification.new do |gem|
5-
gem.name = "typescript-node"
5+
gem.name = 'typescript-node'
66

7-
gem.authors = ["KAWACHI Takashi"]
8-
gem.email = ["[email protected]"]
7+
gem.authors = ['KAWACHI Takashi']
8+
gem.email = ['[email protected]']
99
gem.description = %q{TypeScript ruby interface using Node.js}
1010
gem.summary = gem.description
11-
gem.homepage = "https://github.com/typescript-ruby/typescript-node-ruby"
11+
gem.homepage = 'https://github.com/typescript-ruby/typescript-node-ruby'
1212

1313
gem.files = `git ls-files`.split($\)
1414
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1515
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
1616
gem.require_paths = ["lib"]
1717
gem.version = TypeScript::Node::VERSION
1818

19-
gem.add_dependency 'typescript-src', '~> 1.0.1'
19+
gem.add_dependency 'typescript-src', '~> 1.4.1'
2020
gem.add_development_dependency 'rake'
2121

22-
gem.required_ruby_version = ">= 1.9.3"
22+
gem.required_ruby_version = '>= 1.9.3'
2323
end

0 commit comments

Comments
 (0)