beyond
Version:
The Full Stack Universal Typescript Framework
53 lines (44 loc) • 1.63 kB
JavaScript
const DynamicProcessor = global.utils.DynamicProcessor();
const {crc32, equal} = global.utils;
module.exports = class extends DynamicProcessor {
get dp() {
return 'processor.analyzer.hash';
}
get analyzer() {
return this.
}
constructor(analyzer) {
super();
this.
const events = ['item.initialised', 'item.change'];
const {processor} = analyzer;
const {files, overwrites, extensions} = processor.sources;
const children = [
['files', {child: files, events}],
['extensions', {child: extensions, events}]
];
overwrites && children.push(['overwrites', {child: overwrites, events}]);
super.setup(new Map(children));
}
get value() {
return this.
}
_prepared(check) {
const {files, overwrites} = this.
files.forEach(source => check(source));
overwrites?.forEach(source => check(source));
}
_process() {
const {files, overwrites, extensions} = this.
const compute = {};
files.forEach(source => compute[source.file] = source.hash);
overwrites?.forEach(source => compute[source.file] = source.hash);
extensions.forEach(source => compute[source.file] = source.hash);
const value = crc32(equal.generate(compute));
const changed = value !== this.
this.
return changed;
}
}