diff --git a/CHANGES.md b/CHANGES.md index dc70be4..5dd2cb8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## v1.4.1 2015-07-06 22:36:25+0300 + +* Added stdout to output when Typescript compilation error occurs + ## v1.1.1 2015-04-19 15:40:00+0900 * Use capture3 instead of popen3 to handle tsc I/O. diff --git a/lib/typescript-node.rb b/lib/typescript-node.rb index 5c4dabd..6d37807 100644 --- a/lib/typescript-node.rb +++ b/lib/typescript-node.rb @@ -1,9 +1,9 @@ -require "tmpdir" -require "tempfile" -require "typescript-src" -require "typescript-node/version" -require "typescript-node/compile_result" -require "open3" +require 'tmpdir' +require 'tempfile' +require 'typescript-src' +require 'typescript-node/version' +require 'typescript-node/compile_result' +require 'open3' module TypeScript module Node @@ -23,15 +23,15 @@ def tsc(*args) # @return [TypeScript::Node::CompileResult] compile result def compile_file(source_file, *tsc_options) Dir.mktmpdir do |output_dir| - output_file = File.join(output_dir, "out.js") + output_file = File.join(output_dir, 'out.js') stdout, stderr, exit_status = tsc(*tsc_options, '--out', output_file, source_file) output_js = File.exists?(output_file) ? File.read(output_file) : nil CompileResult.new( - output_js, - exit_status, - stdout, - stderr, + output_js, + exit_status, + stdout, + stderr, ) end end @@ -40,7 +40,7 @@ def compile_file(source_file, *tsc_options) # @param [String] source TypeScript to be compiled # @return [String] Resulted JavaScript def compile(source, *tsc_options) - js_file = Tempfile.new(["typescript-node", ".ts"]) + js_file = Tempfile.new(%w(typescript-node .ts)) begin js_file.write(source) js_file.close @@ -48,7 +48,7 @@ def compile(source, *tsc_options) if result.success? result.js else - raise result.stderr + raise result.stderr + result.stdout end ensure js_file.unlink @@ -58,11 +58,11 @@ def compile(source, *tsc_options) # node command # TS_NODE environmental variable is used when it is set. def node - ENV["TS_NODE"] || "node" + ENV['TS_NODE'] || 'node' end def locate_executable(cmd) - if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ && File.extname(cmd) == "" + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ && File.extname(cmd) == "" cmd << ".exe" end @@ -79,12 +79,11 @@ def locate_executable(cmd) def check_node unless locate_executable(node) - 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." + 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." end end end end end -TypeScript::Node.check_node +TypeScript::Node.check_node \ No newline at end of file diff --git a/lib/typescript-node/version.rb b/lib/typescript-node/version.rb index a5db653..a5c409b 100644 --- a/lib/typescript-node/version.rb +++ b/lib/typescript-node/version.rb @@ -1,5 +1,5 @@ module TypeScript module Node - VERSION = '1.1.1' + VERSION = '1.4.1' end end diff --git a/test/test_typescript-node.rb b/test/test_typescript-node.rb index 2e23783..335d4c2 100644 --- a/test/test_typescript-node.rb +++ b/test/test_typescript-node.rb @@ -28,8 +28,7 @@ def test_compile_file_in_failure assert { subject.exit_status != 0 } assert { !subject.success? } - assert { subject.stdout == '' } - assert { subject.stderr != '' } + assert { subject.stdout != '' || subject.stderr != '' } end def test_compile_file_with_es5 diff --git a/typescript-node.gemspec b/typescript-node.gemspec index 262b8ee..7789fc3 100644 --- a/typescript-node.gemspec +++ b/typescript-node.gemspec @@ -2,13 +2,13 @@ require File.expand_path('../lib/typescript-node/version', __FILE__) Gem::Specification.new do |gem| - gem.name = "typescript-node" + gem.name = 'typescript-node' - gem.authors = ["KAWACHI Takashi"] - gem.email = ["tkawachi@gmail.com"] + gem.authors = ['KAWACHI Takashi'] + gem.email = ['tkawachi@gmail.com'] gem.description = %q{TypeScript ruby interface using Node.js} gem.summary = gem.description - gem.homepage = "https://github.com/typescript-ruby/typescript-node-ruby" + gem.homepage = 'https://github.com/typescript-ruby/typescript-node-ruby' gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } @@ -16,8 +16,8 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.version = TypeScript::Node::VERSION - gem.add_dependency 'typescript-src', '~> 1.0.1' + gem.add_dependency 'typescript-src', '~> 1.4.1' gem.add_development_dependency 'rake' - gem.required_ruby_version = ">= 1.9.3" + gem.required_ruby_version = '>= 1.9.3' end