Converted leftover CommonJS scripts to ESModule.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { pathToFileURL } = require('url');
|
||||
const { parseArgs } = require('util');
|
||||
import { execSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
function execCommand(command, description) {
|
||||
try {
|
||||
@@ -71,7 +74,7 @@ function showHelp() {
|
||||
console.log(`Build multi-architecture container images for JMESPath Playground
|
||||
|
||||
Usage:
|
||||
build-image.js [OPTIONS]
|
||||
build-image.mjs [OPTIONS]
|
||||
|
||||
Options:
|
||||
--all-arch Build for both arm64 and amd64 (default: build for host architecture only)
|
||||
@@ -79,11 +82,11 @@ Options:
|
||||
--help, -h Show this help message and exit
|
||||
|
||||
Examples:
|
||||
build-image.js # Builds for ${hostArch} only (host architecture)
|
||||
build-image.js --all-arch # Builds for both arm64 and amd64
|
||||
build-image.js --arch arm64 # Builds for arm64 only
|
||||
build-image.js --arch arm64 --arch amd64 # Explicitly specify both
|
||||
build-image.js -h # Show help`);
|
||||
build-image.mjs # Builds for ${hostArch} only (host architecture)
|
||||
build-image.mjs --all-arch # Builds for both arm64 and amd64
|
||||
build-image.mjs --arch arm64 # Builds for arm64 only
|
||||
build-image.mjs --arch arm64 --arch amd64 # Explicitly specify both
|
||||
build-image.mjs -h # Show help`);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -150,10 +153,10 @@ async function main() {
|
||||
|
||||
// Show usage instructions
|
||||
console.log(`\nUsage examples:`);
|
||||
console.log(` build-image.js # Builds for host architecture only`);
|
||||
console.log(` build-image.js --all-arch # Builds for both arm64 and amd64`);
|
||||
console.log(` build-image.js --arch arm64 # Builds for arm64 only`);
|
||||
console.log(` build-image.js --arch arm64 --arch amd64 # Explicitly specify both`);
|
||||
console.log(` build-image.mjs # Builds for host architecture only`);
|
||||
console.log(` build-image.mjs --all-arch # Builds for both arm64 and amd64`);
|
||||
console.log(` build-image.mjs --arch arm64 # Builds for arm64 only`);
|
||||
console.log(` build-image.mjs --arch arm64 --arch amd64 # Explicitly specify both`);
|
||||
|
||||
if (isRelease) {
|
||||
console.log(`\nTo run the container:`);
|
||||
@@ -169,7 +172,10 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
const isDirectRun = process.argv[1]
|
||||
&& fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
||||
|
||||
if (isDirectRun) {
|
||||
main().catch((error) => {
|
||||
console.error(`Error: ${error.message}`);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user