adjust proto hash
This commit is contained in:
1 parent
7756a53dfd
commit
91feca8d8c
2 files changed
+14
-2
No files matched your search
@@ -1,5 +1,5 @@
|
||||
' Auto-generated file - do not modify manually
|
||||
' md5:ab48a52d517ca819a9720973f690d0e5
|
||||
' md5:a67e7e5809b87399b499043edf609988
|
||||
|
||||
import "pkg:/source/Protobuf/BinaryReader.bs"
|
||||
import "pkg:/source/Protobuf/BinaryWriter.bs"
|
||||
|
||||
@@ -14,6 +14,8 @@ const protobufSchema = require('protocol-buffers-schema')
|
||||
export class ProtoGenPlugin implements CompilerPlugin {
|
||||
public name = 'ProtoGenPlugin';
|
||||
|
||||
private currentFileHash: string | undefined;
|
||||
|
||||
afterProgramCreate(program: Program) {
|
||||
// @ts-ignore
|
||||
program.options.forceGenerateProtos = true;
|
||||
@@ -38,7 +40,7 @@ export class ProtoGenPlugin implements CompilerPlugin {
|
||||
program.logger.info(`Generating proto from ${protoFile}`);
|
||||
|
||||
const protoContent = readFileSync(protoFile, 'binary');
|
||||
const protoHash = md5(protoContent).toString();
|
||||
const protoHash = md5(protoContent + this.getCurrentFileHash()).toString();
|
||||
|
||||
if (!forceGenerateProtos && existsSync(outputFile)) {
|
||||
const firstLine = readFileSync(outputFile, 'utf8').split('\n')[1];
|
||||
@@ -248,6 +250,16 @@ end function`;
|
||||
|
||||
return new Formatter(options);
|
||||
}
|
||||
|
||||
getCurrentFileHash() {
|
||||
// hash current file (this plugin) - if it changes, it invalidates all generated files
|
||||
if (this.currentFileHash) {
|
||||
return this.currentFileHash;
|
||||
}
|
||||
const pluginContent = readFileSync(__filename, 'binary');
|
||||
this.currentFileHash = md5(pluginContent).toString();
|
||||
return this.currentFileHash;
|
||||
}
|
||||
}
|
||||
|
||||
export default () => {
|
||||
|
||||
Reference in new issue
Block a user