Skip to content

Commit

Permalink
Merge pull request #11357 from endlessm/kolibri-tools-more-namespaces
Browse files Browse the repository at this point in the history
kolibri-tools: Accept multiple --namespace/--searchPath arguments
  • Loading branch information
rtibbles authored Oct 8, 2023
2 parents a5992fb + f7442ef commit 358bb82
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions packages/kolibri-tools/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ function _generatePathInfo({
})
);
}
if (namespace && searchPath) {
if (namespace.length && namespace.length == searchPath.length) {
let aliases;
if (webpackConfig) {
const webpack = require('webpack');
Expand All @@ -528,19 +528,25 @@ function _generatePathInfo({
}
aliases = buildConfig.resolve.alias;
}
pathInfoArray.push({
moduleFilePath: searchPath,
namespace: namespace,
name: namespace,
aliases,
});
for (let i = 0; i < namespace.length; i++) {
pathInfoArray.push({
moduleFilePath: searchPath[i],
namespace: namespace[i],
name: namespace[i],
aliases,
});
}
}
if (pathInfoArray.length) {
return pathInfoArray;
}
cliLogging.error('This command requires one or more of the following combinations of arguments:');
cliLogging.error('1) The --pluginFile, --plugins, or --pluginPath argument.');
cliLogging.error('2) The --searchPath argument along with the --namespace argument.');
cliLogging.error('2) One or more pairs of the --searchPath and --namespace arguments.');
}

function _collect(value, previous) {
return previous.concat([value]);
}

function _addPathOptions(cmd) {
Expand All @@ -564,7 +570,12 @@ function _addPathOptions(cmd) {
list,
langIgnoreDefaults.length ? langIgnoreDefaults : ignoreDefaults
)
.option('-n , --namespace <namespace>', 'Set namespace for string extraction')
.option(
'-n , --namespace <namespace>',
'Set namespace for string extraction; this may be specified multiple times, but there must be an equal number of --searchPath arguments',
_collect,
[]
)
.option(
'--localeDataFolder <localeDataFolder>',
'Set path to write locale files to',
Expand All @@ -573,7 +584,9 @@ function _addPathOptions(cmd) {
)
.option(
'--searchPath <searchPath>',
'Set path to search for files containing strings to be extracted'
'Set path to search for files containing strings to be extracted; this may be specified multiple times, but there must be an equal number of --namespace arguments',
_collect,
[]
)
.option(
'--webpackConfig <webpackConfig>',
Expand Down

0 comments on commit 358bb82

Please sign in to comment.