Skip to content

Commit 980e024

Browse files
committed
Refactor push.js to streamline platform handling and improve code readability
1 parent 159f889 commit 980e024

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

push.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@ const img = 'nozich/bunode'
55
async function main() {
66
await $`docker pull ${img}:latest`
77

8-
// linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/arm/v7, linux/arm/v6
8+
// Anil's MB Pro 250225: linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/arm/v7, linux/arm/v6
99
const inspect = await $`docker buildx inspect | grep 'Platforms:' | sed 's/Platforms: //'`.text();
1010

1111
// Manuelly set the platforms
12-
const inspects = [];
13-
if (inspect.includes('linux/arm64')) {
14-
inspects.push('linux/arm64');
15-
}
16-
if (inspect.includes('linux/amd64')) {
17-
inspects.push('linux/amd64');
18-
}
19-
12+
const inspectionList = [];
13+
if (inspect.includes('linux/arm64')) { inspectionList.push('linux/arm64'); }
14+
if (inspect.includes('linux/amd64')) { inspectionList.push('linux/amd64'); }
15+
const inspects = inspectionList.join(',');
2016
console.log(`inspects`, inspects);
2117

22-
const platforms = inspects.split(',').map(e => e.trim()).map((p) => ({
18+
const platforms = inspects.join(',').split(',').map(e => e.trim()).map((p) => ({
2319
platform: p,
2420
os: p.split('/')[0],
2521
arch: p.split('/')[1],
@@ -32,8 +28,7 @@ async function main() {
3228
const built = (await Promise.all(platforms.map(async ({ platform, tag }) => {
3329
console.log({ platform, img, tag });
3430

35-
const build = await $`docker buildx build --platform=${platform} -t ${img}:${tag} --push .`.text()
36-
.catch((e) => e);
31+
const build = await $`docker buildx build --platform=${platform} -t ${img}:${tag} --push .`;
3732

3833
console.log({ platform, tag, build });
3934

0 commit comments

Comments
 (0)