npm-pipeline-rails 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e04615211140d67774af0ad6d62705b210d7fe0a
4
- data.tar.gz: 0857f5f24eeb6012f9f87ba96d8d065614e8127c
3
+ metadata.gz: 3e7d1f0bbbc5528467366b105a01c0cd3902810d
4
+ data.tar.gz: 10bb84ce836e8cf1981d6e7db3a2824817076362
5
5
  SHA512:
6
- metadata.gz: 067dee14278cebeb98f2132df66e65683ecf70473b2c181dc01e6875f1759b4fc3b380223c0ce229d761582c9f9c0383a80c6cc874a5405182ea4591d6bf5380
7
- data.tar.gz: 47eb06a1433e22d9e508def1e9d7b44caef4fe2bd5e8c3db2d6289cf158d17c6eee8ff82eb78ecde6c20217bef31cf6e57e9771afabb5bb564ad27b4141cef60
6
+ metadata.gz: dd7fc64611ecc66733d8fbc682a886ae7d65a0b420849159bf90b98078a01a2b2cd9e6adcec8e9ae59cd2bc0e50f0efa3b456851736af7d8701c341e61e51730
7
+ data.tar.gz: a0d4c0359e2f916321f9c03e9266f569a0c1850d26332714b68bfd78be4f7510a44b2d610c1e4f0c821559595281ab6ab43d46615cdc017ec723666fc8752045
data/HISTORY.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [v1.4.0]
2
+ > Apr 20, 2016
3
+
4
+ - [#3] - Prevent orphaned processes from accumulating. ([#4])
5
+
6
+ [v1.4.0]: https://github.com/rstacruz/npm-pipeline-rails/compare/v1.3.0...v1.4.0
7
+
1
8
  ## [v1.3.0]
2
9
  > Apr 11, 2016
3
10
 
@@ -49,3 +56,5 @@
49
56
  [v1.0.0]: https://github.com/rstacruz/npm-pipeline-rails/tree/v1.0.0
50
57
  [#1]: https://github.com/rstacruz/npm-pipeline-rails/issues/1
51
58
  [@victorsolis]: https://github.com/victorsolis
59
+ [#3]: https://github.com/rstacruz/npm-pipeline-rails/issues/3
60
+ [#4]: https://github.com/rstacruz/npm-pipeline-rails/issues/4
@@ -3,17 +3,35 @@ require 'rails/railtie'
3
3
 
4
4
  module NpmPipelineRails
5
5
  module Utils
6
+ module_function
7
+
8
+ def log(str)
9
+ ::Rails.logger.debug "[npm-pipeline-rails] #{str}"
10
+ end
11
+
6
12
  def do_system(commands)
7
13
  [*commands].each do |cmd|
14
+ Utils.log "starting '#{cmd}'"
8
15
  system cmd
16
+ Utils.log "'#{cmd}' exited with #{$?.exitstatus} status"
9
17
  exit $?.exitstatus unless $?.exitstatus == 0
10
18
  end
11
19
  end
20
+
21
+ # Runs a block in the background. When the parent exits, the child
22
+ # will be asked to exit as well.
23
+ def background(name, &blk)
24
+ pid = fork(&blk)
25
+
26
+ at_exit do
27
+ Utils.log "Terminating '#{name}' [#{pid}]"
28
+ Process.kill 'TERM', pid
29
+ Process.wait pid
30
+ end
31
+ end
12
32
  end
13
33
 
14
34
  class Railtie < ::Rails::Railtie
15
- include ::NpmPipelineRails::Utils
16
-
17
35
  config.npm = ActiveSupport::OrderedOptions.new
18
36
  config.npm.build = ['npm run build']
19
37
  config.npm.watch = ['npm run start']
@@ -23,8 +41,8 @@ module NpmPipelineRails
23
41
  namespace :assets do
24
42
  desc 'Build asset prerequisites using npm'
25
43
  task :npm_build do
26
- do_system app.config.npm.install
27
- do_system app.config.npm.build
44
+ Utils.do_system app.config.npm.install
45
+ Utils.do_system app.config.npm.build
28
46
  end
29
47
 
30
48
  task(:precompile).enhance ['npm_build']
@@ -33,9 +51,9 @@ module NpmPipelineRails
33
51
 
34
52
  initializer 'npm_pipeline.watch' do |app|
35
53
  if ::Rails.env.development? && ::Rails.const_defined?(:Server)
36
- do_system app.config.npm.install
54
+ Utils.do_system app.config.npm.install
37
55
  [*app.config.npm.watch].each do |cmd|
38
- fork { do_system [cmd] }
56
+ Utils.background(cmd) { Utils.do_system [cmd] }
39
57
  end
40
58
  end
41
59
  end
@@ -1,3 +1,3 @@
1
1
  module NpmPipelineRails
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: npm-pipeline-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rico Sta. Cruz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties