Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Plugin
{
shouldBuild() {
return this.inputs.hasChanges();
}
build() {
for (let input of this.inputs) {
input.readFileSync('path/to/file');
}
this.output.writeFileSync('path/to/file', 'content'); // here we know about changes
}
}
class DirectoryArray {
construct(directories) {
this.directories = directories;
}
hasChanges() {
for (let directory of this.directories) {
if (directory.hasChanges()) {
return true;
}
}
return false;
}
}
// brocfile.js
const source = 'src';
const funnel1 = funnel(source, {files: ['index.html', 'index.js']});
// funnel1.outputPath == '/tmp/assdasdas/funnel-1-out'
const funnel2 = funnel('public', {files: ['index.css']});
// funnel2.outputPath == '/tmp/assdasdas/funnel-2-out'
const funnel3 = funnel(funnel1, {files: ['index.html']});
// funnel3.inputPaths[0] = /tmp/assdasdas/funnel-1-out
// funnel3.outputPath == '/tmp/assdasdas/funnel-3-out'
const funnel4 = merge([funnel1, funnel2, funnel3]);
// funnel4.inputPaths[0] = /tmp/assdasdas/funnel-1-out
return funnel3;
class DirectoryRevision
{
construct(directory) {
this.directory = directory;
this.revision = 0;
}
hasChanges() {
return patch.length > 0;
}
getChanges() {
const current = FSTree.fromEntries(walkSync.entries(inputPath));
return current.calculatePatch(this.previous);
}
settleState() {
const changes = this.getChanges();
if (changes.length > 0) {
this.previous = changes;
this.revision++;
return true;
}
return false;
}
getRevision() {
return this.revision;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.