A simple, powerful CLI tool to spin up OpenIndiana virtual machines with QEMU

Refactor disk size checks to use EMPTY_DISK_THRESHOLD_KB constant for consistency

Changed files
+4 -2
src
+1
src/constants.ts
··· 1 1 export const CONFIG_DIR = `${Deno.env.get("HOME")}/.openindiana-up`; 2 2 export const DB_PATH = `${CONFIG_DIR}/state.sqlite`; 3 + export const EMPTY_DISK_THRESHOLD_KB: number = 100;
+3 -2
src/utils.ts
··· 2 2 import { createId } from "@paralleldrive/cuid2"; 3 3 import chalk from "chalk"; 4 4 import Moniker from "moniker"; 5 + import { EMPTY_DISK_THRESHOLD_KB } from "./constants.ts"; 5 6 import { generateRandomMacAddress } from "./network.ts"; 6 7 import { saveInstanceState } from "./state.ts"; 7 8 ··· 37 38 } 38 39 39 40 const size = await du(path); 40 - return size < 10; 41 + return size < EMPTY_DISK_THRESHOLD_KB; 41 42 } 42 43 43 44 export async function downloadIso( ··· 49 50 50 51 if (options.image && await Deno.stat(options.image).catch(() => false)) { 51 52 const driveSize = await du(options.image); 52 - if (driveSize > 10) { 53 + if (driveSize > EMPTY_DISK_THRESHOLD_KB) { 53 54 console.log( 54 55 chalk.yellowBright( 55 56 `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`,