tsc-ruby 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4e0f93422504eb3b5eb3035b4df949b4df8d8de
4
- data.tar.gz: 8ba113a859ff426dae87e60dda597c90ef66a901
3
+ metadata.gz: 83d301484bc34fd67282b5e6129557d4e762a72d
4
+ data.tar.gz: 848471b0a2d0098e57b90285f47dbba303381952
5
5
  SHA512:
6
- metadata.gz: c348182e2ae7860a10257763cd1b565b144bb2dba37d7d10d8e8a117586449279cc4f1341b2656c7cbed6e9db8687f35385b9bb82be31d19b350bc4fd7bd932a
7
- data.tar.gz: bf82d0a967525de89e6d83116684c096dae6b331a41d9719cb15224d10c18b6d2fbeb843eb4f374d7de1a22761df68f56526ab9e37178c46ebeb0d61cbeb7f3a
6
+ metadata.gz: 4d2926b4e0e6279a11bc757745c83fa7d67fe5e88f8248549463fd7a33c23dafcbd870e1f50eaeb5562a4fd73f186b71031f922778d940dd52c9ab3d6eda8880
7
+ data.tar.gz: 4a915aeb1e6e898c78fae5cdcb351ef2ad44f35f5a1c8617af02a423cc6025533102e4787409472b30364aceb3f3dced4f3d54a5111fc506c724de38bf67fcd7
data/lib/tsc-ruby.rb CHANGED
@@ -29,18 +29,18 @@ module TypeScript
29
29
  # @return [String] compiled JavaScript
30
30
  def compile(script, *tsc_options)
31
31
  script = script.read if script.respond_to?(:read)
32
- js_file = Tempfile.new(%w(tsc-ruby .ts))
32
+ input_file = Tempfile.new(%w(tsc-ruby .ts))
33
33
  begin
34
- js_file.write(script)
35
- js_file.close
36
- result = compile_file(js_file.path, *tsc_options)
34
+ input_file.write(script)
35
+ input_file.close
36
+ result = compile_file(input_file.path, *tsc_options)
37
37
  if result.success?
38
38
  result.js
39
39
  else
40
40
  raise result.stderr + result.stdout
41
41
  end
42
42
  ensure
43
- js_file.unlink
43
+ input_file.unlink
44
44
  end
45
45
  end
46
46
 
@@ -50,11 +50,13 @@ module TypeScript
50
50
  #
51
51
  # @param [String] TypeScript script file
52
52
  # @return [TypeScript::Ruby::CompileResult] compile result
53
- def compile_file(source_file, *tsc_options)
53
+ def compile_file(input_file_path, *tsc_options)
54
54
  Dir.mktmpdir do |output_dir|
55
- stdout, stderr, exit_status = tsc(*tsc_options, '--outDir', output_dir, source_file)
56
- output_file = "#{File.join(output_dir, File.basename(source_file, '.ts'))}.js"
57
- output_js = File.exist?(output_file) ? File.read(output_file) : nil
55
+ stdout, stderr, exit_status = tsc(*tsc_options, '--outDir', output_dir, input_file_path)
56
+ # now input file is in output_dir but with a .js extension
57
+ output_file_path = File.join(output_dir, File.basename(input_file_path, '.ts')) + '.js'
58
+ raise "Compiled JS file not found: #{output_file_path}" unless File.exist? output_file_path
59
+ output_js = File.read(output_file_path)
58
60
  CompileResult.new(output_js, exit_status, stdout, stderr)
59
61
  end
60
62
  end
@@ -1,5 +1,5 @@
1
1
  module TypeScript
2
2
  module Ruby
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Vasilyev