Skip to content

Commit c614a25

Browse files
committed
refactor: Add bundle-core helper
1 parent 12fb2a5 commit c614a25

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

nu/moonbit.nu

+16-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export def 'setup moonbit' [
6464
cd $MOONBIT_BIN_DIR
6565
let OS_INFO = $'($nu.os-info.name)_($nu.os-info.arch)'
6666
let archive = $ARCH_TARGET_MAP | get -i $OS_INFO
67-
let moonBin = if (windows?) { 'moon.exe' } else { 'moon' }
6867
if ($archive | is-empty) { print $'Unsupported Platform: ($OS_INFO)'; exit 2 }
6968

7069
print $'(char nl)Setup moonbit toolchain of version: (ansi g)($version)(ansi reset)'; hr-line
@@ -103,8 +102,7 @@ export def 'setup moonbit' [
103102
if $version == 'bleeding' {
104103
if ($coreDir | path exists) { rm -rf $coreDir }
105104
git clone --depth 1 https://github.com/moonbitlang/core.git $coreDir
106-
^$moonBin bundle --all --source-dir $coreDir
107-
^$moonBin bundle --target wasm-gc --source-dir $coreDir --quiet
105+
bundle-core $coreDir
108106
return
109107
}
110108

@@ -115,8 +113,23 @@ export def 'setup moonbit' [
115113
} else {
116114
tar xf core*.tar.gz --directory $MOONBIT_LIB_DIR; rm core*.tar.gz
117115
}
116+
bundle-core $coreDir
117+
}
118+
}
119+
120+
# Bundle moonbit core
121+
def bundle-core [coreDir: string] {
122+
let moonBin = if (windows?) { 'moon.exe' } else { 'moon' }
123+
print $'(char nl)Bundle moonbit core(ansi reset)'; hr-line
124+
try {
118125
^$moonBin bundle --all --source-dir $coreDir
126+
} catch {
127+
print $'(ansi red)Failed to bundle core(ansi reset)'
128+
}
129+
try {
119130
^$moonBin bundle --target wasm-gc --source-dir $coreDir --quiet
131+
} catch {
132+
print $'(ansi red)Failed to bundle core to wasm-gc(ansi reset)'
120133
}
121134
}
122135

0 commit comments

Comments
 (0)