guard-webpack 0.0.2 → 0.1.0
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 +4 -4
- data/README.md +4 -0
- data/guard-webpack.gemspec +1 -1
- data/lib/guard/webpack.rb +6 -6
- data/lib/guard/webpack/runner.rb +56 -61
- data/lib/guard/webpack/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b235e14f3e29416722eb385c9a1b8738ca13a2
|
4
|
+
data.tar.gz: 0fad6068220f49408ca76983cc2d1eff649fabe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4208130ddae1e6c265c97492e99630f3a28da88d76ff0153f8e6046efa520ecc44ee0e33a52e487b38fd3927dc1657dda8d5c3c9acbca8c9f46823b963941d6
|
7
|
+
data.tar.gz: 43191e2d12702c3747c2de4c7517284eec699904e2c1c578869be65490c6a7c8e3a62d2019cf1a2c6a228da4bdcbe8c79d13e73aa340cd54816ab13ed77c8378
|
data/README.md
CHANGED
@@ -43,6 +43,10 @@ colors: true # use colors in displaying webpack output, default: true
|
|
43
43
|
progress: true # display a progress bar for long compiles, default: true
|
44
44
|
```
|
45
45
|
|
46
|
+
## Notes on Guard 1.x
|
47
|
+
|
48
|
+
Guard::Webpack strives to support older versions of Guard (including the `Guard::Guard`, rather than `Guard::Plugin` syntax. However, support may be limited. Options, as specified above, are not supported for versions of Guard below 2.0.
|
49
|
+
|
46
50
|
## Contributing
|
47
51
|
|
48
52
|
1. Fork it ( https://github.com/gisikw/guard-webpack/fork )
|
data/guard-webpack.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'guard', '
|
20
|
+
spec.add_runtime_dependency 'guard', '< 3.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
data/lib/guard/webpack.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'guard/webpack/version'
|
2
|
-
require 'guard/webpack/runner'
|
3
|
-
|
4
1
|
module Guard
|
5
|
-
class Webpack < Guard::Plugin
|
2
|
+
class Webpack < ::Guard.const_get(::Guard.const_defined?(:Plugin) ? :Plugin : :Guard)
|
3
|
+
require 'guard/webpack/version'
|
4
|
+
require 'guard/webpack/runner'
|
6
5
|
|
7
6
|
DEFAULT_OPTIONS = {
|
8
7
|
progress: true,
|
@@ -11,10 +10,11 @@ module Guard
|
|
11
10
|
|
12
11
|
attr_accessor :runner
|
13
12
|
|
14
|
-
def initialize(
|
15
|
-
with_defaults(
|
13
|
+
def initialize(*args)
|
14
|
+
with_defaults(args[-1]) do |opts|
|
16
15
|
super(opts)
|
17
16
|
@runner = Runner.new(opts)
|
17
|
+
@runner.start
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/guard/webpack/runner.rb
CHANGED
@@ -1,76 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Runner
|
1
|
+
class Guard::Webpack::Runner
|
2
|
+
attr_accessor :options, :thread
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@options = options
|
9
|
-
end
|
10
|
-
|
11
|
-
def restart; stop; start; end
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
12
7
|
|
13
|
-
|
14
|
-
unless_running do
|
15
|
-
@thread = Thread.new { run_webpack }
|
16
|
-
::Guard::UI.info "Webpack watcher started."
|
17
|
-
end
|
18
|
-
end
|
8
|
+
def restart; stop; start; end
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
10
|
+
def start
|
11
|
+
unless_running do
|
12
|
+
@thread = Thread.new { run_webpack }
|
13
|
+
::Guard::UI.info "Webpack watcher started."
|
14
|
+
end
|
15
|
+
end
|
26
16
|
|
27
|
-
|
17
|
+
def stop
|
18
|
+
if_running do
|
19
|
+
@thread.kill
|
20
|
+
::Guard::UI.info "Webpack watcher stopped."
|
21
|
+
end
|
22
|
+
end
|
28
23
|
|
29
|
-
|
30
|
-
bin = File.join(Dir.pwd,'node_modules/webpack/bin/webpack.js')
|
31
|
-
File.exists?(bin) && bin
|
32
|
-
end
|
24
|
+
private
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
def local_webpack
|
27
|
+
bin = File.join(Dir.pwd,'node_modules/webpack/bin/webpack.js')
|
28
|
+
File.exists?(bin) && bin
|
29
|
+
end
|
37
30
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
31
|
+
def global_webpack
|
32
|
+
system("command -v webpack >/dev/null") && 'webpack'
|
33
|
+
end
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
def no_webpack
|
36
|
+
# TODO: This is a bad error.
|
37
|
+
raise 'Webpack binary not found'
|
38
|
+
end
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
output += " --progress" if @options[:progress]
|
51
|
-
output
|
52
|
-
end
|
40
|
+
def webpack_bin
|
41
|
+
local_webpack || global_webpack || no_webpack
|
42
|
+
end
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
::Guard::UI.error "Webpack unable to start (are you sure it's installed?)"
|
61
|
-
ensure
|
62
|
-
Process.kill('TERM',pid)
|
63
|
-
end
|
64
|
-
end
|
44
|
+
def option_flags
|
45
|
+
output = ""
|
46
|
+
output += " --colors" if @options[:colors]
|
47
|
+
output += " --progress" if @options[:progress]
|
48
|
+
output
|
49
|
+
end
|
65
50
|
|
66
|
-
|
67
|
-
|
68
|
-
|
51
|
+
def run_webpack
|
52
|
+
begin
|
53
|
+
pid = fork{ exec("#{webpack_bin} --watch #{option_flags}") }
|
54
|
+
Process.wait(pid)
|
55
|
+
rescue
|
56
|
+
# TODO: Be more discerning.
|
57
|
+
::Guard::UI.error "Webpack unable to start (are you sure it's installed?)"
|
58
|
+
ensure
|
59
|
+
Process.kill('TERM',pid)
|
60
|
+
end
|
61
|
+
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
def unless_running
|
64
|
+
yield if !@thread || !@thread.alive?
|
65
|
+
end
|
73
66
|
|
74
|
-
|
67
|
+
def if_running
|
68
|
+
yield if @thread && @thread.alive?
|
75
69
|
end
|
70
|
+
|
76
71
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-webpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gisi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|