Bug 35079: Replace --force-extract by --generate-pot={always,auto,never}

This restores the original behaviour of always building the POT file
in order to not break existing workflows
Option --force-extract is deleted in favor of a new option
--generate-pot that can have 3 values:

* always: always build the POT file. This is the default value
* auto: build the POT file only if it does not exist
* never: never build the POT file

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Julian Maurice 2023-10-17 17:13:55 +02:00 committed by Tomas Cohen Arazi
parent 0584a2016e
commit 05f33b4fcb
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -19,7 +19,7 @@ const exec = require('gulp-exec');
const merge = require('merge-stream'); const merge = require('merge-stream');
const through2 = require('through2'); const through2 = require('through2');
const Vinyl = require('vinyl'); const Vinyl = require('vinyl');
const args = require('minimist')(process.argv.slice(2)); const args = require('minimist')(process.argv.slice(2), { default: { 'generate-pot': 'always' } });
const rename = require('gulp-rename'); const rename = require('gulp-rename');
const STAFF_CSS_BASE = "koha-tmpl/intranet-tmpl/prog/css"; const STAFF_CSS_BASE = "koha-tmpl/intranet-tmpl/prog/css";
@ -262,7 +262,11 @@ function po_create_type (type) {
// Generate .pot only if it doesn't exist or --force-extract is given // Generate .pot only if it doesn't exist or --force-extract is given
const extract = () => stream.finished(poTasks[type].extract()); const extract = () => stream.finished(poTasks[type].extract());
const p = args['force-extract'] ? extract() : access(pot).catch(extract); const p =
args['generate-pot'] === 'always' ? extract() :
args['generate-pot'] === 'auto' ? access(pot).catch(extract) :
args['generate-pot'] === 'never' ? Promise.resolve(0) :
Promise.reject(new Error('Invalid value for option --generate-pot: ' + args['generate-pot']))
return p.then(function () { return p.then(function () {
const languages = getLanguages(); const languages = getLanguages();
@ -299,7 +303,11 @@ function po_update_type (type) {
// Generate .pot only if it doesn't exist or --force-extract is given // Generate .pot only if it doesn't exist or --force-extract is given
const extract = () => stream.finished(poTasks[type].extract()); const extract = () => stream.finished(poTasks[type].extract());
const p = args['force-extract'] ? extract() : access(pot).catch(extract); const p =
args['generate-pot'] === 'always' ? extract() :
args['generate-pot'] === 'auto' ? access(pot).catch(extract) :
args['generate-pot'] === 'never' ? Promise.resolve(0) :
Promise.reject(new Error('Invalid value for option --generate-pot: ' + args['generate-pot']))
return p.then(function () { return p.then(function () {
const languages = getLanguages(); const languages = getLanguages();