@@ -14,34 +14,34 @@ def main [] {
1414 } else {
1515 $native_package_root | path join bin $binary_name
1616 }
17- let cargo_binary = ( $repo_root | path join rust target release $binary_name )
17+ let cargo_binary = $repo_root | path join rust target release $binary_name
1818 let version = (expected_version $repo_root )
19- if (( native_package_includes_binary $native_package_root $binary_name ) and (has_expected_version $native_binary $version ) ) {
19+ if (native_package_includes_binary $native_package_root $binary_name ) and (has_expected_version $native_binary $version ) {
2020 if not (is_portable_binary $target_platform $native_binary ) {
21- error make {
22- msg : $" ($native_binary ) depends on dynamic libraries that do not exist on end-user machines; rebuild it \( Linux packages must be static, macOS packages may only link system dylibs)"
23- }
21+ error make {msg : $" ($native_binary ) depends on dynamic libraries that do not exist on end-user machines; rebuild it \( Linux packages must be static, macOS packages may only link system dylibs)" }
2422 }
2523 exit 0
2624 }
2725 ^ cargo build -- manifest-path ($repo_root | path join rust Cargo.toml ) -- release -- bin ccusage
2826 if not (has_expected_version $cargo_binary $version ) {
29- error make {
30- msg : $" ($cargo_binary ) did not report version ($version ) after cargo build"
31- }
27+ error make {msg : $" ($cargo_binary ) did not report version ($version ) after cargo build" }
28+ }
29+ }
30+ def node_platform [] {
31+ match $nu .os-info.name {
32+ ' macos' => ' darwin'
33+ ' linux' => ' linux'
34+ ' windows' => ' win32'
35+ $other => $other
36+ }
37+ }
38+ def node_arch [] {
39+ match $nu .os-info.arch {
40+ ' aarch64' => ' arm64'
41+ ' x86_64' => ' x64'
42+ $other => $other
3243 }
3344}
34- def node_platform [] { match $nu .os-info.name {
35- ' macos' => ' darwin'
36- ' linux' => ' linux'
37- ' windows' => ' win32'
38- $other => $other
39- } }
40- def node_arch [] { match $nu .os-info.arch {
41- ' aarch64' => ' arm64'
42- ' x86_64' => ' x64'
43- $other => $other
44- } }
4545def matching_native_package_root [repo_root : path , target_platform : string , target_arch : string ] {
4646 let candidates = (glob ($repo_root | path join packages ' ccusage-*' package.json ) | each {|package_json_path |
4747 let package_json = (open $package_json_path )
@@ -57,8 +57,8 @@ def matching_native_package_root [repo_root: path, target_platform: string, targ
5757}
5858def list_contains [value , needle : string ] { (($value | describe ) =~ ' ^list' ) and ($value | any {|item | $item == $needle }) }
5959def expected_version [repo_root : path ] {
60- let package_json = ( open ($repo_root | path join apps ccusage package.json ) )
61- if (( $package_json.version ? | describe ) != ' string' ) {
60+ let package_json = open ($repo_root | path join apps ccusage package.json )
61+ if ($package_json.version ? | describe ) != ' string' {
6262 error make {msg : ' apps/ccusage/package.json version is not configured' }
6363 }
6464 $package_json.version
@@ -67,7 +67,7 @@ def native_package_includes_binary [package_root, binary_name: string] {
6767 if $package_root == null {
6868 false
6969 } else {
70- let package_json_path = ( $package_root | path join package.json )
70+ let package_json_path = $package_root | path join package.json
7171 if not ($package_json_path | path exists ) {
7272 false
7373 } else {
@@ -89,7 +89,15 @@ def is_portable_binary [target_platform: string, binary] {
8989 if $result.exit_code != 0 {
9090 false
9191 } else {
92- let dylibs = ($result.stdout | lines | skip 1 | each {|line | $line | str trim } | where {|line | ($line | is-not-empty ) } | each {|line | $line | split row -- regex ' \s+' | get -- optional 0 } | where {|dylib | $dylib != null and ($dylib | is-not-empty ) })
92+ let dylibs = (
93+ $result.stdout
94+ | lines
95+ | skip 1
96+ | each {|line | $line | str trim }
97+ | where {|line | ($line | is-not-empty ) }
98+ | each {|line | $line | split row -- regex ' \s+' | get -- optional 0 }
99+ | where {|dylib | $dylib != null and ($dylib | is-not-empty ) }
100+ )
93101 $dylibs | all {|dylib |
94102 $system_dylib_prefixes | any {|prefix | $dylib | str starts-with $prefix }
95103 }
@@ -102,11 +110,16 @@ def has_expected_version [binary, version: string] {
102110 if $binary == null or not ($binary | path exists ) {
103111 false
104112 } else {
105- let result = ( run-external $binary ' --version' | complete )
113+ let result = run-external $binary ' --version' | complete
106114 if $result.exit_code != 0 {
107115 false
108116 } else {
109- let actual_version = ($result.stdout | str trim | split row -- regex ' \s+' | last )
117+ let actual_version = (
118+ $result.stdout
119+ | str trim
120+ | split row -- regex ' \s+'
121+ | last
122+ )
110123 $actual_version == $version
111124 }
112125 }
0 commit comments