js2coffee 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/js2coffee +1 -1
- data/lib/js2coffee/coffee_compiler.rb +2 -2
- data/lib/js2coffee/compiler.rb +1 -1
- data/lib/js2coffee/js_compiler.rb +2 -2
- data/lib/js2coffee/path_helper.rb +13 -29
- data/lib/js2coffee/version.rb +1 -1
- data/lib/js2coffee/watcher.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f5e8fc3d77c373dcb01d744ea74329e228d736
|
4
|
+
data.tar.gz: df3c643915d6bc2593ceb7a54257cefbb96efa6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806ef54442e0857e080458dbe798d3446185019b29039a86219e1c3684d03e00c2a5295d53a7254fab0615051e1e3d0d5f8920a90d2274d0ef81e73c835be63f
|
7
|
+
data.tar.gz: 27cd6718bb81eac9e2841865050b4c3faf3d0d13e6cbec55cb822d9608bb5f37b67e9af5069df805c927044aed98306f29b43dc0c8744e3a891a3d87d959eba4
|
data/bin/js2coffee
CHANGED
@@ -51,7 +51,7 @@ if filename.any?
|
|
51
51
|
else
|
52
52
|
filename.each do |file|
|
53
53
|
unless File.exist? file
|
54
|
-
puts "
|
54
|
+
puts "Can't open \`\033[0;33m#{file}\033[0m' for reading: No such file or directory, Skipping"
|
55
55
|
next
|
56
56
|
end
|
57
57
|
Js2coffee.compile_file(file, bare: true, sourceMap: true)
|
@@ -8,7 +8,7 @@ require 'js2coffee/compiler'
|
|
8
8
|
|
9
9
|
module Js2coffee
|
10
10
|
class CoffeeCompiler < Compiler
|
11
|
-
self.source = 'coffee-script'
|
11
|
+
self.source = 'coffee-script.js'
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def wrapper
|
@@ -32,7 +32,7 @@ WRAPPER
|
|
32
32
|
def watch_file(file)
|
33
33
|
file_path = Pathname(file)
|
34
34
|
source_code = file_path.read
|
35
|
-
target_file, target_map = Js2coffee::PathHelper.new(file_path).
|
35
|
+
target_file, target_map = Js2coffee::PathHelper.new(file_path).create_target_path!
|
36
36
|
# generate js and SourceMap.
|
37
37
|
result = compiler.call(wrapper, source_code, bare: false, sourceMap: true,
|
38
38
|
sourceFiles: [file_path.relative_path_from(target_file.dirname).to_s],
|
data/lib/js2coffee/compiler.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Js2coffee
|
5
5
|
class JsCompiler < Compiler
|
6
|
-
self.source = 'js2coffee'
|
6
|
+
self.source = 'js2coffee.js'
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def wrapper
|
@@ -31,7 +31,7 @@ WRAPPER
|
|
31
31
|
def watch_file(file)
|
32
32
|
file_path = Pathname(file)
|
33
33
|
source_code = file_path.read
|
34
|
-
target_file, target_map = Js2coffee::PathHelper.new(file_path).
|
34
|
+
target_file, target_map = Js2coffee::PathHelper.new(file_path).create_target_path!
|
35
35
|
# generate coffee and SourceMap.
|
36
36
|
result = compiler.call(wrapper, source_code)
|
37
37
|
target_file.write(result['code'])
|
@@ -6,44 +6,28 @@ module Js2coffee
|
|
6
6
|
@path = Pathname(path)
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def create_target_path!
|
10
10
|
# if find `coffee' in descend path, will create js directory at the same level.
|
11
|
-
path.
|
12
|
-
|
13
|
-
js_path = path.sub('/coffee/', '/js/').sub_ext('.js')
|
14
|
-
map_path = path.sub('/coffee/', '/.map/').sub_ext('.js.map')
|
15
|
-
|
16
|
-
FileUtils.mkdir_p([js_path.dirname, map_path.dirname])
|
17
|
-
|
18
|
-
return [js_path, map_path]
|
19
|
-
end
|
20
|
-
end
|
11
|
+
ext = path.extname[1..-1]
|
12
|
+
target = ext == 'js' ? 'coffee' : 'js'
|
21
13
|
|
22
|
-
# else, just save in the same path with new extname.
|
23
|
-
js_path = path.sub_ext('.js')
|
24
|
-
map_path = path.sub_ext('.js.map').sub(/\/([^\/]+)$/, '/.\1')
|
25
|
-
fail 'filename extension must .coffee!' if path == js_path
|
26
|
-
|
27
|
-
[js_path, map_path]
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_coffee_path!
|
31
14
|
path.descend do |x|
|
32
|
-
if x.basename.to_s ==
|
33
|
-
|
34
|
-
map_path = path.sub(
|
15
|
+
if x.basename.to_s == ext
|
16
|
+
target_path = path.sub("/#{ext}/", "/#{target}/").sub_ext(".#{target}")
|
17
|
+
map_path = path.sub("/#{ext}/", '/.map/').sub_ext('.js.map')
|
35
18
|
|
36
|
-
FileUtils.mkdir_p([
|
19
|
+
FileUtils.mkdir_p([target_path.dirname, map_path.dirname])
|
37
20
|
|
38
|
-
return [
|
21
|
+
return [target_path, map_path]
|
39
22
|
end
|
40
23
|
end
|
41
24
|
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
# else, just save in the same path with new extname.
|
26
|
+
target_path = path.sub_ext(".#{target}")
|
27
|
+
map_path = path.sub_ext('.js.map').sub(%r{/([^/]+)$}, '/.\1')
|
28
|
+
fail "filename extension must .#{ext}!" if path == target_path
|
45
29
|
|
46
|
-
[
|
30
|
+
[target_path, map_path]
|
47
31
|
end
|
48
32
|
end
|
49
33
|
end
|
data/lib/js2coffee/version.rb
CHANGED
data/lib/js2coffee/watcher.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js2coffee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Billy.Zheng(zw963)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|