mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 19:47:44 -04:00
!997 fix resource target change bug
Merge pull request !997 from 卡哥/OpenHarmony-3.1-Release
This commit is contained in:
@@ -65,6 +65,7 @@ function initProjectConfig(projectConfig) {
|
||||
projectConfig.cachePath = projectConfig.cachePath || process.env.cachePath ||
|
||||
path.resolve(__dirname, 'node_modules/.cache');
|
||||
projectConfig.aceSoPath = projectConfig.aceSoPath || process.env.aceSoPath;
|
||||
projectConfig.xtsMode = /ets_loader_ark$/.test(__dirname);
|
||||
}
|
||||
|
||||
function loadEntryObj(projectConfig) {
|
||||
@@ -337,6 +338,37 @@ function hashProjectPath(projectPath) {
|
||||
return process.env.hashProjectPath;
|
||||
}
|
||||
|
||||
function checkAppResourcePath(appResourcePath, config) {
|
||||
if (appResourcePath) {
|
||||
readAppResource(resources, appResourcePath);
|
||||
if (fs.existsSync(appResourcePath) && config.cache) {
|
||||
config.cache.buildDependencies.config.push(appResourcePath);
|
||||
}
|
||||
if (!projectConfig.xtsMode) {
|
||||
const appResourcePathSavePath = path.resolve(projectConfig.cachePath, 'resource_path.txt');
|
||||
saveAppResourcePath(appResourcePath, appResourcePathSavePath);
|
||||
if (fs.existsSync(appResourcePathSavePath) && config.cache) {
|
||||
config.cache.buildDependencies.config.push(appResourcePathSavePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveAppResourcePath(appResourcePath, appResourcePathSavePath) {
|
||||
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
|
||||
@@ -351,3 +383,4 @@ exports.loadWorker = loadWorker;
|
||||
exports.abilityConfig = abilityConfig;
|
||||
exports.readWorkerFile = readWorkerFile;
|
||||
exports.systemModules = systemModules;
|
||||
exports.checkAppResourcePath = checkAppResourcePath;
|
||||
|
||||
@@ -24,10 +24,10 @@ const {
|
||||
projectConfig,
|
||||
loadEntryObj,
|
||||
readAppResource,
|
||||
resources,
|
||||
loadWorker,
|
||||
abilityConfig,
|
||||
readWorkerFile
|
||||
readWorkerFile,
|
||||
checkAppResourcePath
|
||||
} = require('./main');
|
||||
const { ResultStates } = require('./lib/compile_info');
|
||||
const { processUISyntax } = require('./lib/process_ui_syntax');
|
||||
@@ -349,12 +349,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;
|
||||
}
|
||||
Reference in New Issue
Block a user