fix : merge develop

This commit is contained in:
2026-03-13 10:18:10 +01:00
parent 92ed9b040f
commit 35cfcb1bcf

View File

@@ -1,4 +1,4 @@
import { execFile } from "child_process"
import { exec, execFile } from "child_process"
import diskSources from "../config/disk-commands.json"
type DiskSource = {
@@ -8,7 +8,7 @@ type DiskSource = {
args?: string[]
}
function getCommand(source: DiskSource) {
function getEnvCommand(source: DiskSource) {
const envKey = `DISK_COMMAND_${source.key.toUpperCase()}`
const legacyEnvKey =
source.key === "remote" ? "DISK_REMOTE_COMMAND" : source.key === "local" ? "DISK_LOCAL_COMMAND" : ""
@@ -28,17 +28,26 @@ function runCommand(command: string, args: string[] = []): Promise<string> {
})
}
function runShellCommand(command: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject(stderr || error.message)
return
}
resolve(stdout)
})
})
}
export default defineEventHandler(async () => {
const results = await Promise.all(
(diskSources as DiskSource[]).map(async (source) => {
try {
const command = getCommand(source)
if (!command) {
throw new Error(`Commande manquante pour ${source.key}`)
}
const output = await runCommand(command)
const envCommand = getEnvCommand(source)
const output = envCommand
? await runShellCommand(envCommand)
: await runCommand(source.command, source.args || [])
return {
key: source.key,
label: source.label,