-
Notifications
You must be signed in to change notification settings - Fork 2
/
WebCell.js
35 lines (30 loc) · 817 Bytes
/
WebCell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
var mode = process.env.CELL_MODE || "development";
var util = require("util");
var Cell = require("organic").Cell;
var DNA = require("organic").DNA;
var Chemical = require("organic").Chemical;
module.exports = function WebCell(dna, callback) {
if(dna) {
Cell.call(this, dna);
if(callback) callback();
} else {
var self = this;
dna = new DNA();
dna.loadDir(process.cwd()+"/dna", function(){
if(dna[mode])
dna.mergeBranchInRoot(mode);
Cell.call(self, dna);
if(callback) callback();
});
}
}
util.inherits(module.exports, Cell);
module.exports.prototype.kill = function(){
this.plasma.emit("kill");
}
// start the cell if this file is not required
if(!module.parent) {
console.log("creating WebCell in "+mode);
new module.exports();
}