Skip to content

Commit

Permalink
fix it fr this time
Browse files Browse the repository at this point in the history
  • Loading branch information
IncognitoTGT committed May 19, 2024
1 parent 8ad9def commit 0ed82c9
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/lib/drizzle/seed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dotenv/config";

import { execSync } from "node:child_process";
import { exec } from "node:child_process";
import { db, image as imageSchema } from "@/lib/drizzle/db";

(async () => {
Expand Down Expand Up @@ -32,12 +32,26 @@ import { db, image as imageSchema } from "@/lib/drizzle/db";
]
const insertion = await db.insert(imageSchema).values(images).onConflictDoNothing().returning()
console.log(`✨Stardust: Seeded ${insertion.length} images.`)
console.log(`✨Stardust: Seeded ${insertion.map((i) => i.dockerImage).join(", ")}`)
console.log(`✨Stardust: Seeded ${insertion.map((i) => i.dockerImage).join(", ") || "no images"}`)
if (process.argv.includes("--pull")) {
console.log("Pulling images...")
for (const image of images) {
execSync(`docker pull ${image.dockerImage}`)
for (let i = 0; i < images.length; i++) {
const image = images[i]
await new Promise<void>((resolve, reject) => {
exec(`docker pull ${image.dockerImage}`, (err, stdout, stderr) => {
if (err) {
console.error(`✨Stardust: Error pulling image ${image.dockerImage}`)
console.error(stderr)
console.error(err)
reject(err)
} else {
console.log(stdout)
console.log(`✨Stardust: Pulled image ${image.dockerImage}`)
resolve()
}
})
})
}
}
process.exit();
})();
process.exit()
})()

0 comments on commit 0ed82c9

Please sign in to comment.