version-cli.mjs (500B)
1 // This file has been placed in the public domain. 2 3 import { getBuildInfo } from "./version.mjs"; 4 5 try { 6 const args = process.argv.slice(2); 7 const json = args[0] === "--json"; 8 if (json) args.shift(); 9 if (args.length > 1 || args[0]?.startsWith("-")) { 10 throw Error("usage: version-cli.mjs [--json] [DIRECTORY]"); 11 } 12 const info = getBuildInfo(args[0]); 13 console.log(json ? JSON.stringify(info) : info.version); 14 } catch (error) { 15 console.error(error.message); 16 process.exitCode = 1; 17 }