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