test: check replaced iff translatable comment
All translatable comments should be replaced, but nothing else.
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
d2ecd03013
commit
793fa8fb52
17
curriculum/test/utils/extract-js-comments.js
Normal file
17
curriculum/test/utils/extract-js-comments.js
Normal file
@ -0,0 +1,17 @@
|
||||
const acorn = require('acorn');
|
||||
const { commentToData } = require('./comment-to-data');
|
||||
|
||||
const parser = acorn.Parser;
|
||||
|
||||
function extractComments(js) {
|
||||
let comments = [];
|
||||
const file = { data: {} };
|
||||
parser.parse(js, { onComment: comments, ecmaVersion: 2020 });
|
||||
|
||||
comments
|
||||
.map(({ value }) => value.trim())
|
||||
.forEach(comment => commentToData(file, comment));
|
||||
return file.data;
|
||||
}
|
||||
|
||||
module.exports = extractComments;
|
Reference in New Issue
Block a user