!378 fix card type with i18n file copy bug

Merge pull request !378 from 卡哥/OpenHarmony-3.2-Beta2
This commit is contained in:
openharmony_ci
2022-09-07 09:39:26 +00:00
committed by Gitee
2 changed files with 18 additions and 4 deletions
+17 -3
View File
@@ -87,7 +87,10 @@ class GenAbcPlugin {
newContent = `\n\n\n\n\n\n\n\n\n\n\n\n\n\n` + newContent;
}
const keyPath = key.replace(/\.js$/, firstFileEXT)
writeFileSync(newContent, path.resolve(output, keyPath), key);
writeFileSync(newContent, path.resolve(output, keyPath), key, true);
} else if (output && path.extname(key) === '.json' &&
process.env.DEVICE_LEVEL === 'card' && !checkI18n(key)) {
writeFileSync(assets[key].source(), path.resolve(output, key), key, false);
}
})
});
@@ -98,6 +101,15 @@ class GenAbcPlugin {
}
}
function checkI18n(key) {
const outI18nPath = path.resolve(output, 'i18n', key);
const projectI18nPath = outI18nPath.replace(output, process.env.projectPath);
if (fs.existsSync(projectI18nPath)) {
return true;
}
return false;
}
function checkWorksFile(assetPath, workerFile) {
if (workerFile === null) {
if (assetPath.search("./workers/") !== 0) {
@@ -113,16 +125,18 @@ function checkWorksFile(assetPath, workerFile) {
}
}
}
return true;
}
function writeFileSync(inputString, output, jsBundleFile) {
function writeFileSync(inputString, output, jsBundleFile, isToBin) {
const parent = path.join(output, '..');
if (!(fs.existsSync(parent) && fs.statSync(parent).isDirectory())) {
mkDir(parent);
}
fs.writeFileSync(output, inputString);
if (!isToBin) {
return;
}
if (fs.existsSync(output)) {
let fileSize = fs.statSync(output).size;
intermediateJsBundle.push({path: output, size: fileSize});
+1 -1
View File
@@ -228,7 +228,7 @@ function setArkPlugin(env, workerFile) {
}
config.plugins.push(new GenAbcPlugin(process.env.buildPath, arkDir, nodeJs, workerFile,
env.buildMode === 'debug'))
if (env.buildMode === 'release' && process.env.DEVICE_LEVEL !== 'card') {
if (env.buildMode === 'release') {
config.output.path = path.join(process.env.cachePath, "releaseAssets",
path.basename(process.env.buildPath));
}