Add --ignore CLI argument
This commit is contained in:
Родитель
48b01ef446
Коммит
7682497d0b
6
cli.js
6
cli.js
|
@ -32,6 +32,12 @@ yargs(process.argv.slice(2))
|
||||||
requiresArg: true,
|
requiresArg: true,
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
|
ignore: {
|
||||||
|
alias: 'i',
|
||||||
|
desc: '.properties files to ignore; should match the file path end',
|
||||||
|
requiresArg: true,
|
||||||
|
type: 'array'
|
||||||
|
},
|
||||||
root: {
|
root: {
|
||||||
alias: 'r',
|
alias: 'r',
|
||||||
desc: 'Root of mozilla-central (usually autodetected)',
|
desc: 'Root of mozilla-central (usually autodetected)',
|
||||||
|
|
|
@ -19,8 +19,13 @@ export async function findExternalRefs(ast, options) {
|
||||||
visitLiteral(path) {
|
visitLiteral(path) {
|
||||||
const { value } = path.node
|
const { value } = path.node
|
||||||
if (typeof value === 'string' && value.startsWith('chrome://')) {
|
if (typeof value === 'string' && value.startsWith('chrome://')) {
|
||||||
if (value.endsWith('.xhtml')) xhtmlUriPaths.push(path)
|
if (
|
||||||
if (value.endsWith('.properties')) propertiesUriPaths.push(path)
|
!options.ignore ||
|
||||||
|
options.ignore.every((ignore) => !path.node.value.endsWith(ignore))
|
||||||
|
) {
|
||||||
|
if (value.endsWith('.xhtml')) xhtmlUriPaths.push(path)
|
||||||
|
if (value.endsWith('.properties')) propertiesUriPaths.push(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.traverse(path)
|
this.traverse(path)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +51,13 @@ export async function findExternalRefs(ast, options) {
|
||||||
const bundleTags = parseStringBundleTags(src)
|
const bundleTags = parseStringBundleTags(src)
|
||||||
if (bundleTags.length > 0) {
|
if (bundleTags.length > 0) {
|
||||||
xhtml.push({ uri, path: fp, bundleTags, src })
|
xhtml.push({ uri, path: fp, bundleTags, src })
|
||||||
for (const tag of bundleTags) propUris.add(tag.src)
|
for (const tag of bundleTags) {
|
||||||
|
if (
|
||||||
|
!options.ignore ||
|
||||||
|
options.ignore.every((ignore) => !tag.src.endsWith(ignore))
|
||||||
|
)
|
||||||
|
propUris.add(tag.src)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ const n = types.namedTypes
|
||||||
* format?: string,
|
* format?: string,
|
||||||
* ftlPath?: string,
|
* ftlPath?: string,
|
||||||
* ftlPrefix?: string,
|
* ftlPrefix?: string,
|
||||||
|
* ignore?: string[],
|
||||||
* root?: string,
|
* root?: string,
|
||||||
* title?: string
|
* title?: string
|
||||||
* }} TransformOptions
|
* }} TransformOptions
|
||||||
|
|
Загрузка…
Ссылка в новой задаче