beaver-build 2.1.0 → 2.2.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
  SHA256:
3
- metadata.gz: f4bb2de97dfff1bc417996a2af8f02142dc621202bbfb9d802d1c3eb10b51c60
4
- data.tar.gz: f63c62063efc3b51d105a753f65bd9f6d86df1fb7ae81b0b9a8a1804e4a47650
3
+ metadata.gz: 7c14453e56d234a62a48d99e3151389a8987ad31413fb822e3c239309b3a933b
4
+ data.tar.gz: ad7487c17109c457e5d7d9fbda58a7479599f947f8c74be00623d10c6170627d
5
5
  SHA512:
6
- metadata.gz: 0ec0602f51e96e4ecd4101ca4116b79811b2b64e5976fd1f22a2c5254b46d9c278a64e711cc0701fd7f50121dd81f3c66c46d9581667106a76901f37469c3cc3
7
- data.tar.gz: 9c18afd6a0c36b2fae88d656464b282f517b3401f610e379fea517615fb9e403c26ffed4b6343b65edbe8901944b40a0331bab09de456d3ddd2022ac22bd5c5c
6
+ metadata.gz: fa4a243e27a05613f9e042bd2e2a17419d461b17cef85865bef00ce57f6141e9fe383891ac229c5f9481a256e5785d4f88edd60796e3769255cb6ae8b9ab21c2
7
+ data.tar.gz: 50a9fbb0f1103e13b00025dd84707c8c175b70f906e7a8e49b5806c91185822af4751096b5ac5c278dd7f01f7704d7ef5d3b31eaecd322b7bc02c89b885fde97
data/lib/beaver.rb CHANGED
@@ -60,7 +60,7 @@ class Beaver
60
60
  def call(cmd)
61
61
  _cmd = @commands[cmd.to_sym]
62
62
  if _cmd.nil?
63
- puts "No command called #{cmd} found"
63
+ STDERR.puts "No command called #{cmd} found"
64
64
  exit 1
65
65
  end
66
66
 
@@ -69,11 +69,18 @@ class Beaver
69
69
 
70
70
  # Run this command when it is called, no matter if its dependencies did not change
71
71
  def must_run cmd
72
- cmd = @commands[cmd.to_sym]
73
- if cmd.nil?
74
- puts "\001b[31mNON-FATAL ERROR\001b[0m: Command #{cmd} does not exist, so `must_run` has not effect"
72
+ _cmd = @commands[cmd.to_sym]
73
+ if _cmd.nil?
74
+ STDERR.puts "\001b[31mNON-FATAL ERROR\001b[0m: Command #{cmd} does not exist, so `must_run` has not effect"
75
+ exit 1
75
76
  end
76
- cmd.overwrite_should_run = true
77
+ _cmd.overwrite_should_run = true
78
+
79
+ _cmd.call
80
+ end
81
+
82
+ def set_main(cmd)
83
+ @mainCommand = cmd.to_sym
77
84
  end
78
85
 
79
86
  # Put this at the end of a file
@@ -89,6 +96,11 @@ class Beaver
89
96
  $cache.save # save cache file
90
97
  end
91
98
 
99
+ # Returns all available commands as an array
100
+ def list_commands
101
+ return @commands.map { |k, v| k }
102
+ end
103
+
92
104
  # Clean cache
93
105
  def clean
94
106
  FileUtils.rm_r @cache_loc
@@ -108,3 +120,7 @@ require 'sh'
108
120
  def call(cmd)
109
121
  $beaver.call cmd
110
122
  end
123
+
124
+ def must_run(cmd)
125
+ $beaver.musts_run cmd
126
+ end
data/lib/command.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'file.rb'
2
2
 
3
+ $__BEAVER_SHOULD_RUN_SCOPE = false
4
+
3
5
  class Command
4
6
  attr_accessor :name
5
7
  attr_accessor :fn
@@ -16,9 +18,21 @@ class Command
16
18
 
17
19
  # Execute the command if needed (dependency files changed)
18
20
  def call
21
+ global_alread_defined = $__BEAVER_SHOULD_RUN_SCOPE
22
+ if self.overwrite_should_run
23
+ $__BEAVER_SHOULD_RUN_SCOPE = true
24
+ end
25
+ if $__BEAVER_SHOULD_RUN_SCOPE
26
+ self.overwrite_should_run = true
27
+ end
28
+
19
29
  if self.should_run?
20
30
  self.call_now()
21
31
  end
32
+
33
+ if !global_alread_defined && $__BEAVER_SHOULD_RUN_SCOPE
34
+ $__BEAVER_SHOULD_RUN_SCOPE = false
35
+ end
22
36
  end
23
37
 
24
38
  # Force call the command, even if none of the files changed
@@ -81,6 +95,6 @@ class Command
81
95
  end
82
96
 
83
97
  def cmd(name, deps = nil, &fn)
84
- cmd = Command.new name, deps, fn
98
+ cmd = Command.new name.to_sym, deps, fn
85
99
  $beaver.__appendCommand cmd
86
100
  end
data/lib/file_dep.rb CHANGED
@@ -43,7 +43,7 @@ class FileDep
43
43
  globs = nil
44
44
  if @glob.respond_to? :each
45
45
  # array
46
- globs = glob
46
+ globs = @glob
47
47
  else
48
48
  # string
49
49
  globs = [@glob]
data/lib/sh.rb CHANGED
@@ -13,7 +13,7 @@ def sh(strcmd)
13
13
  if strcmd.is_a?(SilentAll) || strcmd.is_a?(SilentOutput)
14
14
  `#{strcmd}`
15
15
  else
16
- puts `#{strcmd}`
16
+ system "#{strcmd}"
17
17
  end
18
18
 
19
19
  if $beaver.has(:e)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaver-build
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Everaert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack