Last active
August 29, 2015 13:57
-
-
Save ondrek/9466505 to your computer and use it in GitHub Desktop.
Zinken Structure ™
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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