middleman-typescript 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleman-typescript/extension.rb +8 -2
- data/lib/middleman-typescript/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555c6f88f19d571721387a73c4ba28bd98eba1e7
|
4
|
+
data.tar.gz: b32b3776a1749b89cc04ea13342455891a57eaa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7303b0082ca5cd38157669effa6222c20d113e13792fe0f60e92f977484052737b6852606f7229ded0585dbbb98bb7ddfb13986633a927057d34ad81ee4c2a32
|
7
|
+
data.tar.gz: 5713f04b0b098553f6dfd4eea745e1e8ce1598a9f6460b5a43c52f7377a27f54d28deb86ce24cce81aeafbfa7e40b9372c61524bfd4cd2416394b079ab018c9b
|
@@ -4,17 +4,23 @@ require 'pry'
|
|
4
4
|
module Middleman
|
5
5
|
class TypescriptExtension < Extension
|
6
6
|
option :typescript_dir, 'typescripts', 'Set TypeScript dir.'
|
7
|
+
option :target, 'ES5', 'Target version.(Default ES5)'
|
8
|
+
option :no_implicit_any, true, 'Use --noImplicitAny option.(Default true)'
|
7
9
|
def initialize(app, options_hash={}, &block)
|
8
10
|
super
|
9
|
-
app.set :typescript_dir, options.typescript_dir
|
10
11
|
return unless app.environment == :development
|
11
12
|
|
13
|
+
app.set :typescript_dir, options.typescript_dir
|
14
|
+
compile_options = ['--target', options.target]
|
15
|
+
compile_options << '--noImplicitAny' if options.no_implicit_any
|
16
|
+
app.set :typescript_compile_options, compile_options
|
17
|
+
|
12
18
|
app.ready do
|
13
19
|
files.changed do |file|
|
14
20
|
next if File.extname(file) != '.ts'
|
15
21
|
|
16
22
|
file_path = "#{Dir.pwd}/#{file}"
|
17
|
-
result = TypeScript::Node.compile_file(file_path,
|
23
|
+
result = TypeScript::Node.compile_file(file_path, *app.typescript_compile_options)
|
18
24
|
if result.success?
|
19
25
|
file_name = File.basename(file_path).gsub(/\.ts/, '.js')
|
20
26
|
export_dir = source_dir + File.dirname(file_path).sub(source_dir, '').sub(app.typescript_dir, app.js_dir)
|