output changed files

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: I3702dbd32f24058238773dfd5895c63555765953
This commit is contained in:
houhaoyu
2022-08-21 22:16:33 +08:00
parent 4d3106b58b
commit ae2738e094
5 changed files with 33 additions and 10 deletions
+2
View File
@@ -65,6 +65,8 @@ 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.xtsMode = /ets_loader_ark$/.test(__dirname);
}
+18
View File
@@ -223,6 +223,24 @@ 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 = {
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));
}
}
})
compiler.hooks.done.tap('Result States', (stats: Stats) => {
if (projectConfig.isPreview && projectConfig.aceSoPath &&
useOSFiles && useOSFiles.size > 0) {
+7 -7
View File
@@ -180,7 +180,7 @@ export class GenAbcPlugin {
function clearGlobalInfo() {
// fix bug of multi trigger
if (!projectConfig.isPreview) {
if (!process.env.watchMode) {
intermediateJsBundle = [];
moduleInfos = [];
}
@@ -494,7 +494,7 @@ function invokeCluterModuleToAbc(): void {
if (count_ === totalWorkerNumber) {
writeModuleHashJson();
clearGlobalInfo();
if (projectConfig.isPreview) {
if (process.env.watchMode) {
console.info(blue, 'COMPILE RESULT:SUCCESS ', reset);
}
}
@@ -628,7 +628,7 @@ function invokeWorkersToGenAbc(): void {
if (count_ === workerNumber) {
writeHashJson();
clearGlobalInfo();
if (projectConfig.isPreview) {
if (process.env.watchMode) {
console.info(red, 'COMPILE RESULT:SUCCESS ', reset);
}
}
@@ -733,7 +733,7 @@ function writeModuleHashJson(): void {
return;
}
// fix bug of multi trigger
if (!projectConfig.isPreview || delayCount < 1) {
if (!process.env.watchMode || delayCount < 1) {
fs.writeFileSync(hashFilePath, JSON.stringify(moduleHashJsonObject));
}
}
@@ -778,7 +778,7 @@ function filterIntermediateJsBundleByHashJson(buildPath: string, inputPaths: Fil
if (jsonObject[input] === hashInputContentData && jsonObject[abcPath] === hashAbcContentData) {
updateJsonObject[input] = hashInputContentData;
updateJsonObject[abcPath] = hashAbcContentData;
if (!projectConfig.isPreview) {
if (!process.env.watchMode) {
fs.unlinkSync(input);
}
} else {
@@ -806,7 +806,7 @@ function writeHashJson(): void {
const hashAbcContentData: any = toHashData(abcPath);
hashJsonObject[input] = hashInputContentData;
hashJsonObject[abcPath] = hashAbcContentData;
if (!projectConfig.isPreview) {
if (!process.env.watchMode) {
fs.unlinkSync(input);
}
}
@@ -815,7 +815,7 @@ function writeHashJson(): void {
return;
}
// fix bug of multi trigger
if (!projectConfig.isPreview || delayCount < 1) {
if (!process.env.watchMode || delayCount < 1) {
fs.writeFileSync(hashFilePath, JSON.stringify(hashJsonObject));
}
}
+3 -3
View File
@@ -195,7 +195,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP
if (ts.isExportDeclaration(node) && node.exportClause &&
ts.isNamedExports(node.exportClause) && node.exportClause.elements) {
node.exportClause.elements.forEach(item => {
if (projectConfig.isPreview) {
if (process.env.watchMode) {
exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString());
}
if (item.name && ts.isIdentifier(item.name)) {
@@ -225,7 +225,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP
}
if (ts.isExportDeclaration(node) && node.moduleSpecifier &&
ts.isStringLiteral(node.moduleSpecifier)) {
if (projectConfig.isPreview && node.exportClause && ts.isNamedExports(node.exportClause) &&
if (process.env.watchMode && node.exportClause && ts.isNamedExports(node.exportClause) &&
node.exportClause.elements) {
node.exportClause.elements.forEach(item => {
exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString());
@@ -293,7 +293,7 @@ function collectSpecialFunctionNode(node: ts.FunctionDeclaration, asNameFromPare
function isExportEntry(node: ts.ClassDeclaration, log: LogInfo[], entryCollection: Set<string>,
exportCollection: Set<string>, defaultCollection: Set<string>, fileResolvePath: string,
sourceFile: ts.SourceFile): void {
if (projectConfig.isPreview && node && node.decorators) {
if (process.env.watchMode && node && node.decorators) {
let existExport: boolean = false;
let existEntry: boolean = false;
if (node.modifiers) {
+3
View File
@@ -198,6 +198,9 @@ function setProjectConfig(envArgs) {
if (envArgs.cachePath) {
projectConfig.cachePath = envArgs.cachePath;
}
if (envArgs.watchMode) {
projectConfig.watchMode = envArgs.watchMode;
}
}
function setReleaseConfig(config) {