Skip to content

Instantly share code, notes, and snippets.

@ondrek
Last active August 29, 2015 13:57
Show Gist options
  • Save ondrek/9466505 to your computer and use it in GitHub Desktop.
Save ondrek/9466505 to your computer and use it in GitHub Desktop.
Zinken Structure ™
var CreateBuildDirectory = function(callback) {
events.EventEmitter.call(this);
this.on("error", function(error){
throw error;
process.kill();
});
this.on("removed", function(){
this.copyDirectory();
});
this.on("copied", function(){
this.renameDirectory();
});
this.on("renamed", function(){
callback();
});
this.initial();
};
require("util").inherits(CreateBuildDirectory, events.EventEmitter);
CreateBuildDirectory.prototype.removeDirectory = function(){
fse.remove(directory, function(err){
if (err) this.emit("error", err);
this.emit("removed");
});
};
CreateBuildDirectory.prototype.copyDirectory = function(){
fse.copy(directory, function(err){
if (err) this.emit("error", err);
this.emit("copied");
});
};
CreateBuildDirectory.prototype.renameDirectory = function(){
fse.rename(directory, function(err){
if (err) this.emit("error", err);
this.emit("renamed");
});
};
new CreateBuildDirectory();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment