Add CLI option to enable alphabetical sorting of extracted keys
This commit is contained in:
committed by
Kim Biesbjerg
parent
94e6416c76
commit
c18b7dc9c7
@@ -16,6 +16,7 @@ const options = cli.parse({
|
||||
output: ['o', 'Path you would like to save extracted strings to', 'dir', process.env.PWD],
|
||||
format: ['f', 'Output format', ['json', 'pot'], 'json'],
|
||||
replace: ['r', 'Replace the contents of output file if it exists (Merges by default)', 'boolean', false],
|
||||
sort: ['s', 'Sort translations in the output file in alphabetical order', 'boolean', false],
|
||||
clean: ['c', 'Remove obsolete strings when merging', 'boolean', false]
|
||||
});
|
||||
|
||||
@@ -77,6 +78,10 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.sort) {
|
||||
collection = collection.sort();
|
||||
}
|
||||
|
||||
fs.writeFileSync(outputPath, compiler.compile(collection));
|
||||
cli.ok(`* Saved to '${outputPath}'`);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user