Skip to content

Commit

Permalink
Added a force option to the compose cli
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineludeau committed Aug 5, 2024
1 parent 22b04b2 commit 3e77ff0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/compose/cli.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)

Expand Down
9 changes: 8 additions & 1 deletion lib/compose/worker.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3e77ff0

Please sign in to comment.