mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-19 16:43:34 -04:00
fix Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I794a458861f86b77bf42a39bc85d706d112acbf0
This commit is contained in:
+6
-2
@@ -65,13 +65,17 @@ function initProjectConfig(projectConfig) {
|
||||
projectConfig.cachePath = projectConfig.cachePath || process.env.cachePath ||
|
||||
path.resolve(__dirname, 'node_modules/.cache');
|
||||
projectConfig.aceSoPath = projectConfig.aceSoPath || process.env.aceSoPath;
|
||||
projectConfig.outChangedFileList = (projectConfig.watchMode && projectConfig.watchMode.outChangedFileList) ?
|
||||
projectConfig.watchMode.outChangedFileList : path.join(projectConfig.cachePath, 'changedFileList.json');
|
||||
projectConfig.outChangedFileList = getChangedFileList(projectConfig);
|
||||
projectConfig.xtsMode = /ets_loader_ark$/.test(__dirname);
|
||||
projectConfig.localPropertiesPath = projectConfig.localPropertiesPath || process.env.localPropertiesPath
|
||||
projectConfig.projectProfilePath = projectConfig.projectProfilePath || process.env.projectProfilePath
|
||||
}
|
||||
|
||||
function getChangedFileList(projectConfig) {
|
||||
return (projectConfig.hotReloadWatch && projectConfig.hotReloadWatch.outChangedFileList) ?
|
||||
projectConfig.hotReloadWatch.outChangedFileList : path.join(projectConfig.cachePath, 'changedFileList.json');
|
||||
}
|
||||
|
||||
function loadEntryObj(projectConfig) {
|
||||
let manifest = {};
|
||||
initProjectConfig(projectConfig);
|
||||
|
||||
@@ -35,11 +35,13 @@ import {
|
||||
import {
|
||||
circularFile,
|
||||
mkDir,
|
||||
writeFileSync
|
||||
} from './utils';
|
||||
import {
|
||||
MODULE_ETS_PATH,
|
||||
MODULE_SHARE_PATH,
|
||||
BUILD_SHARE_PATH,
|
||||
ESMODULE
|
||||
} from './pre_define';
|
||||
import {
|
||||
createLanguageService,
|
||||
@@ -224,20 +226,26 @@ export class ResultStates {
|
||||
});
|
||||
|
||||
compiler.hooks.watchRun.tap('WatchRun', (comp) => {
|
||||
if (process.env.watchMode && projectConfig.outChangedFileList && (comp.modifiedFiles || comp.removedFiles) &&
|
||||
!(comp.modifiedFiles && [...comp.modifiedFiles].length === 1 && [...comp.modifiedFiles][0] == projectConfig.projectPath)) {
|
||||
const filesObj = {
|
||||
if (comp.modifiedFiles) {
|
||||
const isTsAndEtsFile: boolean = [...comp.modifiedFiles].some((item: string) => {
|
||||
return /.(ts|ets)$/.test(item);
|
||||
});
|
||||
if (!isTsAndEtsFile) {
|
||||
process.env.watchTs = 'end';
|
||||
}
|
||||
}
|
||||
if (this.shouldWriteChangedList(comp)) {
|
||||
interface filesObj {
|
||||
modifiedFiles: string[],
|
||||
removedFiles: string[]
|
||||
}
|
||||
const filesObj: filesObj = {
|
||||
modifiedFiles: [...comp.modifiedFiles].filter((file) => {
|
||||
return fs.statSync(file).isFile();
|
||||
}),
|
||||
removedFiles: [...comp.removedFiles]
|
||||
};
|
||||
if (fs.existsSync(path.dirname(projectConfig.outChangedFileList))) {
|
||||
fs.writeFileSync(projectConfig.outChangedFileList, JSON.stringify(filesObj));
|
||||
} else {
|
||||
fs.mkdirSync(path.dirname(projectConfig.outChangedFileList));
|
||||
fs.writeFileSync(projectConfig.outChangedFileList, JSON.stringify(filesObj));
|
||||
}
|
||||
writeFileSync(projectConfig.outChangedFileList, JSON.stringify(filesObj));
|
||||
}
|
||||
})
|
||||
|
||||
@@ -257,17 +265,13 @@ export class ResultStates {
|
||||
}
|
||||
this.printResult();
|
||||
});
|
||||
}
|
||||
|
||||
compiler.hooks.watchRun.tap('Listening State', (compiler: Compiler) => {
|
||||
if (compiler.modifiedFiles) {
|
||||
const isTsAndEtsFile: boolean = [...compiler.modifiedFiles].some((item: string) => {
|
||||
return /.(ts|ets)$/.test(item);
|
||||
});
|
||||
if (!isTsAndEtsFile) {
|
||||
process.env.watchTs = 'end';
|
||||
}
|
||||
}
|
||||
});
|
||||
private shouldWriteChangedList(comp): boolean {
|
||||
return projectConfig.compileMode === ESMODULE && process.env.watchMode && !projectConfig.isPreview &&
|
||||
projectConfig.outChangedFileList && (comp.modifiedFiles || comp.removedFiles) &&
|
||||
!(comp.modifiedFiles && [...comp.modifiedFiles].length === 1 &&
|
||||
[...comp.modifiedFiles][0] == projectConfig.projectPath);
|
||||
}
|
||||
|
||||
private printDiagnostic(diagnostic: ts.Diagnostic): void {
|
||||
|
||||
@@ -200,7 +200,7 @@ function setProjectConfig(envArgs) {
|
||||
projectConfig.cachePath = envArgs.cachePath;
|
||||
}
|
||||
if (envArgs.watchMode) {
|
||||
projectConfig.watchMode = envArgs.watchMode;
|
||||
projectConfig.hotReloadWatch = envArgs.watchMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user