beaver-build 2.0.0 → 2.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/lib/beaver.rb +13 -0
- data/lib/command.rb +10 -0
- data/lib/file.rb +3 -0
- data/lib/sh.rb +19 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4bb2de97dfff1bc417996a2af8f02142dc621202bbfb9d802d1c3eb10b51c60
|
4
|
+
data.tar.gz: f63c62063efc3b51d105a753f65bd9f6d86df1fb7ae81b0b9a8a1804e4a47650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec0602f51e96e4ecd4101ca4116b79811b2b64e5976fd1f22a2c5254b46d9c278a64e711cc0701fd7f50121dd81f3c66c46d9581667106a76901f37469c3cc3
|
7
|
+
data.tar.gz: 9c18afd6a0c36b2fae88d656464b282f517b3401f610e379fea517615fb9e403c26ffed4b6343b65edbe8901944b40a0331bab09de456d3ddd2022ac22bd5c5c
|
data/lib/beaver.rb
CHANGED
@@ -67,11 +67,23 @@ class Beaver
|
|
67
67
|
_cmd.call
|
68
68
|
end
|
69
69
|
|
70
|
+
# Run this command when it is called, no matter if its dependencies did not change
|
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"
|
75
|
+
end
|
76
|
+
cmd.overwrite_should_run = true
|
77
|
+
end
|
78
|
+
|
70
79
|
# Put this at the end of a file
|
71
80
|
def end
|
72
81
|
$cache = CacheManager.new # load cache file
|
73
82
|
|
74
83
|
command = ARGV[0] || @mainCommand
|
84
|
+
if command == "--" # passing arguments to be processed by the builld file -> pass "--" as the command to specify the default
|
85
|
+
command = @mainCommand
|
86
|
+
end
|
75
87
|
self.call command
|
76
88
|
|
77
89
|
$cache.save # save cache file
|
@@ -80,6 +92,7 @@ class Beaver
|
|
80
92
|
# Clean cache
|
81
93
|
def clean
|
82
94
|
FileUtils.rm_r @cache_loc
|
95
|
+
reset_cache
|
83
96
|
end
|
84
97
|
end
|
85
98
|
|
data/lib/command.rb
CHANGED
@@ -3,6 +3,7 @@ require 'file.rb'
|
|
3
3
|
class Command
|
4
4
|
attr_accessor :name
|
5
5
|
attr_accessor :fn
|
6
|
+
attr_accessor :overwrite_should_run
|
6
7
|
|
7
8
|
def initialize(name, file_deps, fn)
|
8
9
|
@name = name
|
@@ -10,6 +11,7 @@ class Command
|
|
10
11
|
# Type: FileDep, or nil
|
11
12
|
@file_deps = file_deps
|
12
13
|
@fn = fn
|
14
|
+
@overwrite_should_run = false
|
13
15
|
end
|
14
16
|
|
15
17
|
# Execute the command if needed (dependency files changed)
|
@@ -23,6 +25,12 @@ class Command
|
|
23
25
|
def call_now
|
24
26
|
$file = nil
|
25
27
|
$files = nil
|
28
|
+
|
29
|
+
if @file_deps.nil?
|
30
|
+
@fn.call()
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
26
34
|
if @file_deps.type == :each
|
27
35
|
@file_deps.files.each do |file_obj|
|
28
36
|
$file = file_obj
|
@@ -37,6 +45,8 @@ class Command
|
|
37
45
|
# Returns wheter the command should run, meaning if any of the depency
|
38
46
|
# files changed
|
39
47
|
def should_run?
|
48
|
+
return true if @overwrite_should_run
|
49
|
+
|
40
50
|
if changed? "__BEAVER__CONFIG__", $PROGRAM_NAME
|
41
51
|
# Ruby script itself changed
|
42
52
|
# TODO: does not account for dependencies of the script (probably uncommon though)
|
data/lib/file.rb
CHANGED
data/lib/sh.rb
CHANGED
@@ -10,14 +10,21 @@ def sh(strcmd)
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
if strcmd.is_a?
|
13
|
+
if strcmd.is_a?(SilentAll) || strcmd.is_a?(SilentOutput)
|
14
14
|
`#{strcmd}`
|
15
15
|
else
|
16
16
|
puts `#{strcmd}`
|
17
17
|
end
|
18
18
|
|
19
19
|
if $beaver.has(:e)
|
20
|
-
|
20
|
+
if $?.to_i != 0
|
21
|
+
if $?.exitstatus.nil?
|
22
|
+
puts $?
|
23
|
+
end
|
24
|
+
exit($?.exitstatus || -1)
|
25
|
+
end
|
26
|
+
elsif $?.to_i != 0 && $?.exitstatus.nil?
|
27
|
+
puts $?
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -31,6 +38,11 @@ SilentAll = Struct.new(:strcmd) do
|
|
31
38
|
strcmd
|
32
39
|
end
|
33
40
|
end
|
41
|
+
SilentOutput = Struct.new(:strcmd) do
|
42
|
+
def to_s
|
43
|
+
strcmd
|
44
|
+
end
|
45
|
+
end
|
34
46
|
|
35
47
|
# Do not print the command
|
36
48
|
def silent(strcmd)
|
@@ -41,3 +53,8 @@ end
|
|
41
53
|
def full_silent(strcmd)
|
42
54
|
return SilentAll.new(strcmd)
|
43
55
|
end
|
56
|
+
|
57
|
+
# Do not print out the output of the command
|
58
|
+
def output_silent(strcmd)
|
59
|
+
return SilentOutput.new(strcmd)
|
60
|
+
end
|
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.
|
4
|
+
version: 2.1.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-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
version: 1.6.0
|
27
27
|
description: |-
|
28
28
|
Beaver is an easy to understand build tool with a lot of capabilities.
|
29
|
-
Documentation and examples on [github](https://github.com/jomy10/beaver)
|
29
|
+
Documentation and examples on [github](https://github.com/jomy10/beaver).
|
30
30
|
email:
|
31
31
|
executables:
|
32
32
|
- beaver
|