From 3e77ff0b2ac817bb2033b0e2ce0921ec4ccabd0e Mon Sep 17 00:00:00 2001 From: antoineludeau <52679050+antoineludeau@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:28:25 +0200 Subject: [PATCH] Added a force option to the compose cli --- lib/compose/cli.cjs | 3 ++- lib/compose/worker.cjs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/compose/cli.cjs b/lib/compose/cli.cjs index 2d1e2517..44fcf092 100755 --- a/lib/compose/cli.cjs +++ b/lib/compose/cli.cjs @@ -12,10 +12,11 @@ async function main() { // Check if --ignoreIdConfig flag is provided const ignoreIdConfig = argv.ignoreIdConfig || false + const force = argv.force || false await runInParallel( require.resolve('./worker.cjs'), - communes.map(codeCommune => ({codeCommune, ignoreIdConfig})), + communes.map(codeCommune => ({codeCommune, force, ignoreIdConfig})), {maxWorkerMemory: 3072, maxRetries: 5} ) diff --git a/lib/compose/worker.cjs b/lib/compose/worker.cjs index 99e74310..d8fe1731 100644 --- a/lib/compose/worker.cjs +++ b/lib/compose/worker.cjs @@ -4,10 +4,17 @@ const composeCommune = require('./index.cjs') async function main(options) { await mongo.connect() - const {codeCommune, ignoreIdConfig} = options + const {codeCommune, force, ignoreIdConfig} = options console.time(`commune ${codeCommune}`) + if (force) { + await mongo.db.collection('communes').updateOne( + {codeCommune}, + {$set: {compositionOptions: {force: true}}} + ) + } + await composeCommune(codeCommune, ignoreIdConfig) await finishComposition(codeCommune)