@tolgee/cli
Advanced tools
Comparing version
@@ -10,3 +10,3 @@ import { extractString, isString } from './nodeUtils.js'; | ||
} | ||
function keyInfoFromComment(context, line) { | ||
function commentKeyInfoOnLine(context, line) { | ||
const commentAtLine = context.commentMap.get(line - 1); | ||
@@ -16,11 +16,14 @@ const isKeyInfo = commentAtLine?.type === 'MAGIC_COMMENT' && commentAtLine.kind === 'key'; | ||
context.unusedComments.delete(commentAtLine); | ||
return { | ||
keyName: commentAtLine.keyName, | ||
namespace: commentAtLine.namespace ?? context.options.defaultNamespace, | ||
defaultValue: commentAtLine.defaultValue, | ||
line: commentAtLine.line, | ||
}; | ||
return keyInfoFromComment(context, commentAtLine); | ||
} | ||
return undefined; | ||
} | ||
function keyInfoFromComment(context, info) { | ||
return { | ||
keyName: info.keyName, | ||
namespace: info.namespace ?? context.options.defaultNamespace, | ||
defaultValue: info.defaultValue, | ||
line: info.line, | ||
}; | ||
} | ||
function reportKey(context, node, contextNs) { | ||
@@ -33,3 +36,3 @@ const { strictNamespace, defaultNamespace } = context.options; | ||
} | ||
const overrideInfo = keyInfoFromComment(context, node.line); | ||
const overrideInfo = commentKeyInfoOnLine(context, node.line); | ||
if (overrideInfo) { | ||
@@ -152,8 +155,3 @@ // key info is overriten by comment | ||
else if (value.type === 'MAGIC_COMMENT' && value.kind === 'key') { | ||
context.keys.push({ | ||
keyName: value.keyName, | ||
namespace: value.namespace, | ||
defaultValue: value.defaultValue, | ||
line: value.line, | ||
}); | ||
context.keys.push(keyInfoFromComment(context, value)); | ||
} | ||
@@ -160,0 +158,0 @@ else if (value.type === 'MAGIC_COMMENT' && value.kind === 'ignore') { |
{ | ||
"name": "@tolgee/cli", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A tool to interact with the Tolgee Platform through CLI", |
900606
-0.01%4545
-0.04%