guard-webpacker 0.1.1 → 0.2.1

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
  SHA256:
3
- metadata.gz: 57e2d9aadd8941793c882129be5c997788465e871076052f1837be1647954cc3
4
- data.tar.gz: cdb46019c2682d2662f298cdb7ab93c93079b4c90a1957e7abd17293fd95f10b
3
+ metadata.gz: e6f1fa502f7c6061c76d0a4791545deaddcdadcd748400eac1693dbc37da87d3
4
+ data.tar.gz: 49bc7dc0f1f42ee958acdbcdc1a26bca12aac3890ace54d08c446c0d4e9ad68f
5
5
  SHA512:
6
- metadata.gz: cb45ed194212a9ec820f7dd8e27369dc2060532049c554cb58117a45bfffe47309333718a01d7d47435027b963662ad57fe366fa61caeee4d58035555bfdfefb
7
- data.tar.gz: 10a0614dc4491a598b2efda023dc2d27aeab42bea6b8c684e345d7c26a817753c412915396af8f81899cc7f7e31222aec6f48fbc134de40eab486e96769de97a
6
+ metadata.gz: 91f8fdb5097c9e07d2b1fea4ada613b3c92f4a7720191832a5c226048d15eb90524ccfd6ff366e8457478b9841f55eeebc8a51fd822cf7c081c3f2d808787ec4
7
+ data.tar.gz: cfc176e693d82dd8acba7ea243cd746dc8f57311cfe04eda611293364f0daabce0dcbee738000623b652e6a932acf09c25688d864dab079b23b4298d8e5df57f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- guard-webpacker (0.1.1)
4
+ guard-webpacker (0.2.1)
5
5
  guard (>= 2)
6
6
  guard-compat (~> 1.0)
7
7
 
@@ -10,9 +10,9 @@ GEM
10
10
  specs:
11
11
  coderay (1.1.2)
12
12
  diff-lcs (1.3)
13
- ffi (1.11.1)
13
+ ffi (1.11.3)
14
14
  formatador (0.2.5)
15
- guard (2.15.1)
15
+ guard (2.16.1)
16
16
  formatador (>= 0.2.4)
17
17
  listen (>= 2.7, < 4.0)
18
18
  lumberjack (>= 1.0.12, < 2.0)
@@ -22,7 +22,7 @@ GEM
22
22
  shellany (~> 0.0)
23
23
  thor (>= 0.18.1)
24
24
  guard-compat (1.2.1)
25
- listen (3.2.0)
25
+ listen (3.2.1)
26
26
  rb-fsevent (~> 0.10, >= 0.10.3)
27
27
  rb-inotify (~> 0.9, >= 0.9.10)
28
28
  lumberjack (1.0.13)
@@ -38,21 +38,21 @@ GEM
38
38
  rb-fsevent (0.10.3)
39
39
  rb-inotify (0.10.0)
40
40
  ffi (~> 1.0)
41
- rspec (3.8.0)
42
- rspec-core (~> 3.8.0)
43
- rspec-expectations (~> 3.8.0)
44
- rspec-mocks (~> 3.8.0)
45
- rspec-core (3.8.2)
46
- rspec-support (~> 3.8.0)
47
- rspec-expectations (3.8.4)
41
+ rspec (3.9.0)
42
+ rspec-core (~> 3.9.0)
43
+ rspec-expectations (~> 3.9.0)
44
+ rspec-mocks (~> 3.9.0)
45
+ rspec-core (3.9.0)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-expectations (3.9.0)
48
48
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-mocks (3.8.1)
49
+ rspec-support (~> 3.9.0)
50
+ rspec-mocks (3.9.0)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-support (3.8.2)
52
+ rspec-support (~> 3.9.0)
53
+ rspec-support (3.9.0)
54
54
  shellany (0.0.1)
55
- thor (0.20.3)
55
+ thor (1.0.1)
56
56
 
57
57
  PLATFORMS
58
58
  ruby
@@ -64,4 +64,4 @@ DEPENDENCIES
64
64
  rspec (~> 3.0)
65
65
 
66
66
  BUNDLED WITH
67
- 2.0.2
67
+ 2.1.1
@@ -5,19 +5,27 @@ require 'timeout'
5
5
 
6
6
  module Guard
7
7
  class WebPacker < Plugin
8
- DEFAULT_BIN = 'webpack-dev-server'
8
+ DEFAULT_PATH = 'bin'
9
+ WEBPACK_DEV_SERVER = 'webpack-dev-server'
10
+ WEBPACK = 'webpack'
9
11
  DEFAULT_SIGNAL = :TERM
10
12
 
11
13
  def initialize(options = {})
14
+ super
15
+
12
16
  @pid = nil
13
- @bin = options[:bin] || DEFAULT_BIN
17
+ @path = options[:path] || DEFAULT_PATH
18
+ @bin = options[:bin] || WEBPACK_DEV_SERVER
14
19
  @stop_signal = options[:stop_signal] || DEFAULT_SIGNAL
15
- super
16
20
  end
17
21
 
18
22
  def start
19
- stop
20
- Guard::Compat::UI.info "Starting up #{@bin} ..."
23
+ unless File.exist?(File.join(@path, @bin))
24
+ Guard::Compat::UI.info "[Guard::WebPacker::Error] Could not find #{@bin} at #{@path}."
25
+ return false
26
+ end
27
+
28
+ Guard::Compat::UI.info "[Guard::WebPacker] Starting up #{@bin} ..."
21
29
  Guard::Compat::UI.info cmd
22
30
 
23
31
  # launch webpack-dev-server or webpack
@@ -27,23 +35,24 @@ module Guard
27
35
  def stop
28
36
  return unless @pid
29
37
 
30
- Guard::Compat::UI.info "Stopping #{@bin} ..."
38
+ Guard::Compat::UI.info "[Guard::WebPacker] Stopping #{@bin} ..."
31
39
  ::Process.kill @stop_signal, @pid
32
40
  begin
33
41
  Timeout.timeout(15) do
34
42
  ::Process.wait @pid
35
43
  end
36
44
  rescue Timeout::Error
37
- Guard::Compat::UI.info "Sending SIGKILL to #{@bin}, as it\'s taking too long to shutdown."
45
+ Guard::Compat::UI.info "[Guard::WebPacker] Sending SIGKILL to #{@bin}, as it\'s taking too long to shutdown."
38
46
  ::Process.kill :KILL, @pid
39
47
  ::Process.wait @pid
40
48
  end
41
- Guard::Compat::UI.info "Stopped process #{@bin} ..."
49
+ @pid = nil
50
+ Guard::Compat::UI.info "[Guard::WebPacker] Stopped process #{@bin} ..."
42
51
  end
43
52
 
44
53
  # Called on Ctrl-Z signal
45
54
  def reload
46
- Guard::Compat::UI.info "Restarting #{@bin} ..."
55
+ Guard::Compat::UI.info "[Guard::WebPacker] Restarting #{@bin} ..."
47
56
  restart
48
57
  end
49
58
 
@@ -65,12 +74,14 @@ module Guard
65
74
  private
66
75
 
67
76
  def cmd
68
- command = ["bundle exec bin/#{@bin}"]
77
+ command = ["bundle exec #{@path}/#{@bin}"]
69
78
 
70
- if @bin != DEFAULT_BIN
71
- command << '--watch' if @options[:watch]
72
- command << '--colors' if @options[:colors]
73
- command << '--progress' if @options[:progress]
79
+ if @bin == WEBPACK
80
+ command << '--watch' if @options[:watch]
81
+ command << '--colors' if @options[:colors]
82
+ command << '--progress' if @options[:progress]
83
+ command << '--progress' if @options[:progress]
84
+ command << "--mode #{@options[:mode]}" if @options[:mode]
74
85
  end
75
86
 
76
87
  command.join(' ')
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Guard
4
4
  module WebpackerVersion
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-24 00:00:00.000000000 Z
11
+ date: 2019-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard