File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,19 +16,25 @@ struct Command {
1616 var output = " "
1717
1818 let task = Process ( )
19- task. launchPath = cmd
19+
20+ task. executableURL = URL ( fileURLWithPath: cmd)
2021 task. arguments = args
2122
2223 let outpipe = Pipe ( )
2324 task. standardOutput = outpipe
2425
25- task. launch ( )
26+ do {
27+ try task. run ( )
28+ task. waitUntilExit ( )
2629
27- task. waitUntilExit ( )
28- let outdata = outpipe. fileHandleForReading. readDataToEndOfFile ( )
29- if let string = String ( data: outdata, encoding: . utf8) {
30- output = string. trimmingCharacters ( in: . newlines)
30+ let outdata = outpipe. fileHandleForReading. readDataToEndOfFile ( )
31+ if let string = String ( data: outdata, encoding: . utf8) {
32+ output = string. trimmingCharacters ( in: . newlines)
33+ }
34+ } catch {
35+ print ( " Error running command: \( error) " )
3136 }
37+
3238 return output
3339 }
3440}
Original file line number Diff line number Diff line change 11#! /bin/bash
22set -e
33
4+ if [ ! -d " clash.meta" ]; then
5+ echo " Downloading mihomo..."
6+ mkdir clash.meta
7+ # arm64
8+ curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases/latest \
9+ | grep " browser_download_url.*mihomo-darwin-arm64-v.*gz" \
10+ | cut -d ' "' -f 4 \
11+ | xargs curl -L -o clash.meta/mihomo-darwin-arm64.gz
12+
13+ # amd64
14+ curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases/latest \
15+ | grep " browser_download_url.*mihomo-darwin-amd64-v.*gz" \
16+ | cut -d ' "' -f 4 \
17+ | xargs curl -L -o clash.meta/mihomo-darwin-amd64.gz
18+
19+ echo " Download complete."
20+ fi
21+
422echo " Unzip core files"
523cd clash.meta
624ls
You can’t perform that action at this time.
0 commit comments