-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathutils.jq
More file actions
34 lines (32 loc) · 972 Bytes
/
utils.jq
File metadata and controls
34 lines (32 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def filters:
to_entries
| map("$__data\n| \(.value)\n| (. as $__result | $__output | .[\"\(.key)\"] = $__result) as $__output") as $filters
| [". as $__data\n| {} as $__output"] + $filters
| join("\n| ")
| . + "\n| $__output"
;
def bytesize:
.
| if . >= 1099511627776 then "\(. / 1099511627776 * 100 | round / 100)TB"
elif . >= 1073741824 then "\(. / 1073741824 * 100 | round / 100)GB"
elif . >= 1048576 then "\(. / 1048576 * 100 | round / 100)MB"
elif . >= 1024 then "\(. / 1024 * 100 | round / 100)KB"
else "\(.)B"
end
;
def version:
.
| endswith("-dev") as $is_dev
| (. | split("-") | .[0] | split(".") | map(tonumber)) as $parts
| (if $is_dev then "\($parts[0]).\($parts[1]).\($parts[2])"
else "\($parts[0]).\($parts[1]).\($parts[2] + 1)-dev"
end) as $next
| {
version: .,
is_dev: $is_dev,
major: $parts[0],
minor: $parts[1],
patch: $parts[2],
next: $next
}
;