Replace node-getopt with commander for args
node-getopt isn't maintained and nodejs has started complaining about deprecated features in it.
This commit is contained in:
parent
52392ec150
commit
3e2e04bea1
|
@ -56,7 +56,6 @@
|
|||
"karma-safari-launcher": "latest",
|
||||
"karma-script-launcher": "latest",
|
||||
"mocha": "latest",
|
||||
"node-getopt": "latest",
|
||||
"po2json": "latest",
|
||||
"sinon": "latest",
|
||||
"sinon-chai": "latest"
|
||||
|
|
18
po/po2js
18
po/po2js
|
@ -17,20 +17,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const getopt = require('node-getopt');
|
||||
const { program } = require('commander');
|
||||
const fs = require('fs');
|
||||
const po2json = require("po2json");
|
||||
|
||||
const opt = getopt.create([
|
||||
['h', 'help', 'display this help'],
|
||||
]).bindHelp().parseSystem();
|
||||
program
|
||||
.argument('<input>')
|
||||
.argument('<output>')
|
||||
.parse(process.argv);
|
||||
|
||||
if (opt.argv.length != 2) {
|
||||
console.error("Incorrect number of arguments given");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const data = po2json.parseFileSync(opt.argv[0]);
|
||||
const data = po2json.parseFileSync(program.args[0]);
|
||||
|
||||
const bodyPart = Object.keys(data)
|
||||
.filter(msgid => msgid !== "")
|
||||
|
@ -42,4 +38,4 @@ const bodyPart = Object.keys(data)
|
|||
|
||||
const output = "{\n" + bodyPart + "\n}";
|
||||
|
||||
fs.writeFileSync(opt.argv[1], output);
|
||||
fs.writeFileSync(program.args[1], output);
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
const getopt = require('node-getopt');
|
||||
const { program } = require('commander');
|
||||
const jsdom = require("jsdom");
|
||||
const fs = require("fs");
|
||||
|
||||
const opt = getopt.create([
|
||||
['o', 'output=FILE', 'write output to specified file'],
|
||||
['h', 'help', 'display this help'],
|
||||
]).bindHelp().parseSystem();
|
||||
program
|
||||
.argument('<INPUT...>')
|
||||
.requiredOption('-o, --output <FILE>', 'write output to specified file')
|
||||
.parse(process.argv);
|
||||
|
||||
const strings = {};
|
||||
|
||||
|
@ -87,8 +87,8 @@ function process(elem, locator, enabled) {
|
|||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < opt.argv.length; i++) {
|
||||
const fn = opt.argv[i];
|
||||
for (let i = 0; i < program.args.length; i++) {
|
||||
const fn = program.args[i];
|
||||
const file = fs.readFileSync(fn, "utf8");
|
||||
const dom = new jsdom.JSDOM(file, { includeNodeLocations: true });
|
||||
const body = dom.window.document.body;
|
||||
|
@ -116,4 +116,4 @@ for (let str in strings) {
|
|||
output += "\n";
|
||||
}
|
||||
|
||||
fs.writeFileSync(opt.options.output, output);
|
||||
fs.writeFileSync(program.opts().output, output);
|
||||
|
|
Loading…
Reference in New Issue