Skip to content

Commit

Permalink
Add parseScript option to disable parsing JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Junichi Shinohara committed Jan 4, 2019
1 parent 1c4d5a8 commit d55f675
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/extract-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ const endDelimiter = argv.endDelimiter === undefined ? constants.DEFAULT_DELIMIT
const extraAttribute = argv.attribute || false;
const extraFilter = argv.filter || false;
const filterPrefix = argv.filterPrefix || constants.DEFAULT_FILTER_PREFIX;
const parseScript = argv.parseScript === undefined ? true : argv.parseScript === 'true';

if (!quietMode && (!files || files.length === 0)) {
console.log('Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--filterPrefix FILTER-PREFIX] [--output OUTFILE] <FILES>');
console.log(
'Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--filterPrefix FILTER-PREFIX] [--parseScript BOOLEAN] [--output OUTFILE] <FILES>',
);
process.exit(1);
}

Expand Down Expand Up @@ -66,6 +69,10 @@ files.forEach(function(filename) {
let data = fs.readFileSync(file, {encoding: 'utf-8'}).toString();
extractor.parse(file, extract.preprocessTemplate(data, ext));

if (!parseScript) {
return;
}

if (ext !== 'js') {
data = extract.preprocessScriptTags(data, ext);
}
Expand Down

0 comments on commit d55f675

Please sign in to comment.