!974 fix resource target change bug

Merge pull request !974 from 卡哥/master
This commit is contained in:
openharmony_ci
2022-08-22 07:28:13 +00:00
committed by Gitee
2 changed files with 35 additions and 9 deletions
+32
View File
@@ -380,6 +380,37 @@ function loadModuleInfo(projectConfig, envArgs) {
}
}
function checkAppResourcePath(appResourcePath, config) {
if (appResourcePath) {
const appResourcePathSavePath = path.resolve(projectConfig.cachePath, 'resource_path.txt');
saveAppResourcePath(appResourcePath, appResourcePathSavePath);
readAppResource(resources, appResourcePath);
if (fs.existsSync(appResourcePath) && config.cache) {
config.cache.buildDependencies.config.push(appResourcePath);
}
if (fs.existsSync(appResourcePathSavePath) && config.cache) {
config.cache.buildDependencies.config.push(appResourcePathSavePath);
}
}
}
function saveAppResourcePath(appResourcePath, appResourcePathSavePath) {
if (!projectConfig.xtsMode) {
let isSave = false;
if (fs.existsSync(appResourcePathSavePath)) {
const saveContent = fs.readFileSync(appResourcePathSavePath);
if (appResourcePath !== saveContent) {
isSave = true;
}
} else {
isSave = true;
}
if (isSave) {
fs.writeFileSync(appResourcePathSavePath, appResourcePath);
}
}
}
const globalProgram = {
program: null,
watchProgram: null
@@ -396,3 +427,4 @@ exports.readWorkerFile = readWorkerFile;
exports.abilityPagesFullPath = abilityPagesFullPath;
exports.loadModuleInfo = loadModuleInfo;
exports.systemModules = systemModules;
exports.checkAppResourcePath = checkAppResourcePath;
+3 -9
View File
@@ -24,12 +24,11 @@ const buildPipeServer = require('./server/build_pipe_server');
const {
projectConfig,
loadEntryObj,
readAppResource,
resources,
loadWorker,
abilityConfig,
readWorkerFile,
loadModuleInfo
loadModuleInfo,
checkAppResourcePath
} = require('./main');
const { ResultStates } = require('./lib/compile_info');
const { processUISyntax } = require('./lib/process_ui_syntax');
@@ -384,12 +383,7 @@ module.exports = (env, argv) => {
}
const appResourcePath = env.appResource || process.env.appResource;
if (appResourcePath) {
readAppResource(resources, appResourcePath);
if (fs.existsSync(appResourcePath) && config.cache) {
config.cache.buildDependencies.config.push(appResourcePath)
}
}
checkAppResourcePath(appResourcePath, config);
config.output.library = projectConfig.hashProjectPath;
return config;
}