Sfoglia il codice sorgente

task_processor uses its own hash for version control of output files

Stephan Fuchs 2 mesi fa
parent
commit
2ddce8399d
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      task_processor.js

+ 3 - 3
task_processor.js

@@ -9,7 +9,7 @@ import npcInit from "./src/npcInit.js";
 import skillDefinitions from "./src/skillDefinitions.js";
 import wardrobeItems from "./src/wardrobeItems.js";
 
-
+const thisFilesHash = md5(fs.readFileSync(__filename,{encoding: 'utf8'}));
 
 //https://stackoverflow.com/a/25221100/7200161
 function baseFileName(fullpath){
@@ -53,7 +53,7 @@ function convertFile(task){
 						const qsrc2twResult = JSON.parse(qsrc2twResultMatch[1]);
 
 						if((qsrc2twResult.code && codeHash == qsrc2twResult.code) &&
-							(qsrc2twResult.version && VERSION == qsrc2twResult.version)){
+							(qsrc2twResult.version && thisFilesHash == qsrc2twResult.version)){
 								return [0,"EXISTS"];
 						}
 					}
@@ -119,7 +119,7 @@ function convertFile(task){
 				return [2,"Invalid convertFunction"];
 			}else{
 				twineCode = twineCodeRaw.split('\n')
-								.toSpliced(1,0,`<!--qsrc2twResult={"version":${VERSION},"code":"${codeHash}","time":"${(new Date().toISOString())}"}-->`)
+								.toSpliced(1,0,`<!--qsrc2twResult={"version":"${thisFilesHash}","code":"${codeHash}","time":"${(new Date().toISOString())}"}-->`)
 								.join('\n');
 				fs.writeFile(outFilePath, twineCode, err => {
 					if (err) {