1

Workflow de vérification des liens

This commit is contained in:
2025-11-01 16:27:37 +01:00
parent 0f272f94a1
commit 04869a6091
2 changed files with 57 additions and 0 deletions

View File

@@ -1,4 +1,7 @@
{ {
"scripts": {
"links:refresh": "node tools/run_link_checks.js"
},
"dependencies": { "dependencies": {
"postcss-import": "^16.1.0", "postcss-import": "^16.1.0",
"postcss-nested": "^7.0.2", "postcss-nested": "^7.0.2",

54
tools/run_link_checks.js Normal file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env node
const path = require("path");
const { spawn } = require("child_process");
const SITE_ROOT = path.resolve(__dirname, "..");
const steps = [
{ label: "check_internal_links", script: path.join(__dirname, "check_internal_links.js") },
{ label: "check_external_links", script: path.join(__dirname, "check_external_links.js") },
{ label: "update_external_links", script: path.join(__dirname, "update_external_links.js") },
{ label: "mark_dead_links", script: path.join(__dirname, "mark_dead_links.js") },
];
function runStep({ label, script }) {
return new Promise((resolve, reject) => {
const child = spawn("node", [script], {
cwd: SITE_ROOT,
stdio: "inherit",
});
child.on("exit", (code, signal) => {
if (typeof code === "number" && code === 0) {
resolve();
return;
}
const reason =
typeof code === "number"
? `code ${code}`
: signal
? `signal ${signal}`
: "unknown reason";
reject(new Error(`Étape "${label}" terminée avec ${reason}`));
});
child.on("error", (error) => {
reject(new Error(`Impossible d'exécuter "${label}": ${error.message}`));
});
});
}
async function main() {
for (const step of steps) {
const relative = path.relative(SITE_ROOT, step.script);
console.log(`\n➡️ Exécution de ${relative}...`);
await runStep(step);
}
console.log("\n✅ Workflow des liens terminé.");
}
main().catch((error) => {
console.error(`\n❌ Échec du workflow: ${error.message}`);
process.exitCode = 1;
});