official-intl
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -16,6 +16,6 @@ #!/usr/bin/env node | ||
rootDir += 'src/'; | ||
const updateStr = (str, obj, node) => { | ||
const updateStr = (str, obj, tmp) => { | ||
const strTrim = str.trim(); | ||
if (obj[strTrim]) { | ||
node.value = node.value.replace(strTrim, obj[strTrim]); | ||
tmp.content = tmp.content.replaceAll(strTrim, obj[strTrim]); | ||
return true; | ||
@@ -45,2 +45,3 @@ } | ||
let content = fs.readFileSync(`${dir}${f}`).toString(); | ||
const tmp = { content }; | ||
const ast = babelParser.parse(content, { | ||
@@ -59,3 +60,3 @@ sourceType: "module", | ||
if (!/^[\x00-\xff]*$/.test(str)) { | ||
const result = updateStr(v.node.value, obj, v.node); | ||
const result = updateStr(v.node.value, obj, tmp); | ||
hasChange = hasChange || result | ||
@@ -67,3 +68,3 @@ } | ||
if (!/^[\x00-\xff]*$/.test(str)) { | ||
const result = updateStr(v.node.value, obj, v.node); | ||
const result = updateStr(v.node.value, obj, tmp); | ||
hasChange = hasChange || result | ||
@@ -74,3 +75,3 @@ } | ||
if (hasChange) { | ||
fs.writeFileSync(`${dir}${f}`, generate(ast, {}, content ).code); | ||
fs.writeFileSync(`${dir}${f}`, tmp.content); | ||
} | ||
@@ -77,0 +78,0 @@ }); |
{ | ||
"name": "official-intl", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "数数科技官网国际化文案提取和更新工具", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10983
364