mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-18 00:27:17 +00:00
basic monitor
This commit is contained in:
parent
abfeef5595
commit
7b45f8d6ea
@ -105,7 +105,7 @@ Blockchain.prototype.generate_basic_command = function() {
|
|||||||
cmd += "--rpcport " + this.blockchainConfig.rpcPort + " ";
|
cmd += "--rpcport " + this.blockchainConfig.rpcPort + " ";
|
||||||
cmd += "--rpcaddr " + this.blockchainConfig.rpcHost + " ";
|
cmd += "--rpcaddr " + this.blockchainConfig.rpcHost + " ";
|
||||||
cmd += "--networkid " + "12301" + " ";
|
cmd += "--networkid " + "12301" + " ";
|
||||||
cmd += "--rpccorsdomain=\"" + "*" + "\" ";
|
cmd += "--rpccorsdomain=\"" + "localhost" + "\" ";
|
||||||
|
|
||||||
//cmd += "--port " + config.port + " ";
|
//cmd += "--port " + config.port + " ";
|
||||||
//cmd += "--rpc ";
|
//cmd += "--rpc ";
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
var Compiler = require('./compiler.js');
|
var Compiler = require('./compiler.js');
|
||||||
|
|
||||||
var Deploy = function(web3, contractsManager) {
|
var Deploy = function(web3, contractsManager, logger) {
|
||||||
this.web3 = web3;
|
this.web3 = web3;
|
||||||
this.contractsManager = contractsManager;
|
this.contractsManager = contractsManager;
|
||||||
|
this.logger = logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
Deploy.prototype.deployContract = function(contract, params, callback) {
|
Deploy.prototype.deployContract = function(contract, params, callback) {
|
||||||
|
var self = this;
|
||||||
var contractObject = this.web3.eth.contract(contract.abiDefinition);
|
var contractObject = this.web3.eth.contract(contract.abiDefinition);
|
||||||
|
|
||||||
var contractParams = params || contract.args;
|
var contractParams = params || contract.args;
|
||||||
@ -20,10 +22,10 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||||||
|
|
||||||
contractParams.push(function(err, transaction) {
|
contractParams.push(function(err, transaction) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log("error");
|
self.logger.info("error");
|
||||||
callback(new Error(err));
|
callback(new Error(err));
|
||||||
} else if (transaction.address !== undefined) {
|
} else if (transaction.address !== undefined) {
|
||||||
console.log("address contract: " + transaction.address);
|
self.logger.info("address contract: " + transaction.address);
|
||||||
contract.deployedAddress = transaction.address;
|
contract.deployedAddress = transaction.address;
|
||||||
callback(null, transaction.address);
|
callback(null, transaction.address);
|
||||||
}
|
}
|
||||||
@ -34,16 +36,16 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||||||
|
|
||||||
Deploy.prototype.deployAll = function(done) {
|
Deploy.prototype.deployAll = function(done) {
|
||||||
var self = this;
|
var self = this;
|
||||||
console.log("deployAll");
|
this.logger.info("deployAll");
|
||||||
|
|
||||||
async.eachOfSeries(this.contractsManager.listContracts(),
|
async.eachOfSeries(this.contractsManager.listContracts(),
|
||||||
function(contract, key, callback) {
|
function(contract, key, callback) {
|
||||||
console.log(arguments);
|
self.logger.info(arguments);
|
||||||
self.deployContract(contract, null, callback);
|
self.deployContract(contract, null, callback);
|
||||||
},
|
},
|
||||||
function(err, results) {
|
function(err, results) {
|
||||||
console.log("finished");
|
self.logger.info("finished");
|
||||||
console.log(arguments);
|
self.logger.info(arguments);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
20
lib/index.js
20
lib/index.js
@ -19,6 +19,7 @@ var Pipeline = require('./pipeline.js');
|
|||||||
var Test = require('./test.js');
|
var Test = require('./test.js');
|
||||||
var Logger = require('./logger.js');
|
var Logger = require('./logger.js');
|
||||||
var Config = require('./config.js');
|
var Config = require('./config.js');
|
||||||
|
var Monitor = require('./monitor.js');
|
||||||
|
|
||||||
var Embark = {
|
var Embark = {
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ var Embark = {
|
|||||||
initConfig: function(env, options) {
|
initConfig: function(env, options) {
|
||||||
this.config = new Config(env);
|
this.config = new Config(env);
|
||||||
this.config.loadConfigFiles(options);
|
this.config.loadConfigFiles(options);
|
||||||
|
this.logger = new Logger({});
|
||||||
|
|
||||||
//this.contractsManager = new ContractsManager(configDir, files, env);
|
//this.contractsManager = new ContractsManager(configDir, files, env);
|
||||||
//this.contractsManager.init();
|
//this.contractsManager.init();
|
||||||
@ -44,6 +46,11 @@ var Embark = {
|
|||||||
run: function(env) {
|
run: function(env) {
|
||||||
var self = this;
|
var self = this;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
function startMonitor(callback) {
|
||||||
|
Embark.monitor = new Monitor({env: env});
|
||||||
|
self.logger.logFunction = Embark.monitor.setData;
|
||||||
|
callback();
|
||||||
|
},
|
||||||
function deployAndGenerateABI(callback) {
|
function deployAndGenerateABI(callback) {
|
||||||
Embark.deploy(function(abi) {
|
Embark.deploy(function(abi) {
|
||||||
callback(null, abi);
|
callback(null, abi);
|
||||||
@ -53,22 +60,23 @@ var Embark = {
|
|||||||
var pipeline = new Pipeline({
|
var pipeline = new Pipeline({
|
||||||
buildDir: self.config.buildDir,
|
buildDir: self.config.buildDir,
|
||||||
contractsFiles: self.config.contractsFiles,
|
contractsFiles: self.config.contractsFiles,
|
||||||
assetFiles: self.config.assetFiles
|
assetFiles: self.config.assetFiles,
|
||||||
|
logger: self.logger
|
||||||
});
|
});
|
||||||
pipeline.build(abi);
|
pipeline.build(abi);
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function startAssetServer(callback) {
|
function startAssetServer(callback) {
|
||||||
var server = new Server({});
|
var server = new Server({logger: self.logger});
|
||||||
server.start(callback);
|
server.start(callback);
|
||||||
},
|
},
|
||||||
function watchFilesForChanges(callback) {
|
function watchFilesForChanges(callback) {
|
||||||
var watch = new Watch();
|
var watch = new Watch({logger: self.logger});
|
||||||
watch.start();
|
watch.start();
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
], function(err, result) {
|
], function(err, result) {
|
||||||
console.log("finished".underline);
|
self.logger.trace("finished".underline);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -85,7 +93,7 @@ var Embark = {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
], function(err, result) {
|
], function(err, result) {
|
||||||
console.log("finished".underline);
|
self.logger.trace("finished".underline);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -114,7 +122,7 @@ var Embark = {
|
|||||||
var web3Endpoint = 'http://' + self.config.blockchainConfig.rpcHost + ':' + self.config.blockchainConfig.rpcPort;
|
var web3Endpoint = 'http://' + self.config.blockchainConfig.rpcHost + ':' + self.config.blockchainConfig.rpcPort;
|
||||||
web3.setProvider(new web3.providers.HttpProvider(web3Endpoint));
|
web3.setProvider(new web3.providers.HttpProvider(web3Endpoint));
|
||||||
|
|
||||||
var deploy = new Deploy(web3, contractsManager);
|
var deploy = new Deploy(web3, contractsManager, Embark.logger);
|
||||||
deploy.deployAll(function() {
|
deploy.deployAll(function() {
|
||||||
callback(null, contractsManager);
|
callback(null, contractsManager);
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,38 @@
|
|||||||
var colors = require('colors');
|
var colors = require('colors');
|
||||||
|
|
||||||
var Logger = {
|
var Logger = function(options) {
|
||||||
logLevel: 'info',
|
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
||||||
|
this.logLevel = options.logLevel || 'info';
|
||||||
|
this.logFunction = options.logFunction || console.log;
|
||||||
|
};
|
||||||
|
|
||||||
info: function(txt) {
|
Logger.prototype.error = function(txt) {
|
||||||
console.log(txt.blue);
|
if (!(this.shouldLog('error'))) { return; }
|
||||||
},
|
this.logFunction(txt.red);
|
||||||
|
};
|
||||||
|
|
||||||
log: function(txt) {
|
Logger.prototype.warn = function(txt) {
|
||||||
console.log(txt);
|
if (!(this.shouldLog('warn'))) { return; }
|
||||||
},
|
this.logFunction(txt.yellow);
|
||||||
|
};
|
||||||
|
|
||||||
warn: function(txt) {
|
Logger.prototype.info = function(txt) {
|
||||||
console.log(txt.yellow);
|
if (!(this.shouldLog('info'))) { return; }
|
||||||
},
|
this.logFunction(txt.green);
|
||||||
|
};
|
||||||
|
|
||||||
error: function(txt) {
|
Logger.prototype.debug = function(txt) {
|
||||||
console.log(txt.red);
|
if (!(this.shouldLog('debug'))) { return; }
|
||||||
}
|
this.logFunction(txt);
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger.prototype.trace = function(txt) {
|
||||||
|
if (!(this.shouldLog('trace'))) { return; }
|
||||||
|
this.logFunction(txt);
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger.prototype.shouldLog = function(level) {
|
||||||
|
return (this.logLevels.indexOf(level) <= this.logLevels.indexOf(this.logLevel));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Logger;
|
module.exports = Logger;
|
||||||
|
309
lib/monitor.js
Normal file
309
lib/monitor.js
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var blessed = require("blessed");
|
||||||
|
|
||||||
|
//var formatOutput = require("../utils/format-output.js");
|
||||||
|
//var formatModules = require("../utils/format-modules.js");
|
||||||
|
//var formatAssets = require("../utils/format-assets.js");
|
||||||
|
|
||||||
|
function Dashboard(options) {
|
||||||
|
var title = options && options.title || "Embark 2.0";
|
||||||
|
this.env = options.env;
|
||||||
|
|
||||||
|
this.color = options && options.color || "green";
|
||||||
|
this.minimal = options && options.minimal || false;
|
||||||
|
this.setData = this.setData.bind(this);
|
||||||
|
|
||||||
|
this.screen = blessed.screen({
|
||||||
|
smartCSR: true,
|
||||||
|
title: title,
|
||||||
|
dockBorders: false,
|
||||||
|
fullUnicode: true,
|
||||||
|
autoPadding: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.layoutLog.call(this);
|
||||||
|
this.layoutStatus.call(this);
|
||||||
|
this.layoutModules.call(this);
|
||||||
|
this.layoutCmd.call(this);
|
||||||
|
|
||||||
|
this.screen.key(["C-c"], function() {
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.status.setContent(this.env);
|
||||||
|
this.moduleTable.setData([
|
||||||
|
["Contract Name", "Address", "Status"],
|
||||||
|
["SimpleStorage", "0x123", "Deployed".green]
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.screen.render();
|
||||||
|
|
||||||
|
this.input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
Dashboard.prototype.setData = function(dataArr) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.logText.log(dataArr);
|
||||||
|
|
||||||
|
this.screen.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
Dashboard.prototype.layoutLog = function() {
|
||||||
|
this.log = blessed.box({
|
||||||
|
label: "Logs",
|
||||||
|
padding: 1,
|
||||||
|
width: "100%",
|
||||||
|
height: "55%",
|
||||||
|
left: "0%",
|
||||||
|
top: "42%",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.logText = blessed.log({
|
||||||
|
parent: this.log,
|
||||||
|
tags: true,
|
||||||
|
width: "100%-5",
|
||||||
|
//height: '90%',
|
||||||
|
scrollable: true,
|
||||||
|
input: false,
|
||||||
|
alwaysScroll: true,
|
||||||
|
scrollbar: {
|
||||||
|
ch: " ",
|
||||||
|
inverse: true
|
||||||
|
},
|
||||||
|
keys: false,
|
||||||
|
vi: false,
|
||||||
|
mouse: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.screen.append(this.log);
|
||||||
|
};
|
||||||
|
|
||||||
|
Dashboard.prototype.layoutModules = function() {
|
||||||
|
this.modules = blessed.box({
|
||||||
|
label: "Contracts",
|
||||||
|
tags: true,
|
||||||
|
padding: 1,
|
||||||
|
width: "75%",
|
||||||
|
height: "42%",
|
||||||
|
left: "0%",
|
||||||
|
top: "0",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.moduleTable = blessed.table({
|
||||||
|
parent: this.modules,
|
||||||
|
height: "100%",
|
||||||
|
width: "100%-5",
|
||||||
|
align: "left",
|
||||||
|
pad: 1,
|
||||||
|
shrink: true,
|
||||||
|
scrollable: true,
|
||||||
|
alwaysScroll: true,
|
||||||
|
scrollbar: {
|
||||||
|
ch: " ",
|
||||||
|
inverse: true
|
||||||
|
},
|
||||||
|
keys: false,
|
||||||
|
vi: false,
|
||||||
|
mouse: true,
|
||||||
|
data: [["ContractName", "Address", "Status"]]
|
||||||
|
});
|
||||||
|
|
||||||
|
this.screen.append(this.modules);
|
||||||
|
};
|
||||||
|
|
||||||
|
Dashboard.prototype.layoutAssets = function() {
|
||||||
|
this.assets = blessed.box({
|
||||||
|
label: "Asset Pipeline",
|
||||||
|
tags: true,
|
||||||
|
padding: 1,
|
||||||
|
width: "50%",
|
||||||
|
height: "55%",
|
||||||
|
left: "50%",
|
||||||
|
top: "42%",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.assetTable = blessed.table({
|
||||||
|
parent: this.assets,
|
||||||
|
height: "100%",
|
||||||
|
width: "100%-5",
|
||||||
|
align: "left",
|
||||||
|
pad: 1,
|
||||||
|
scrollable: true,
|
||||||
|
alwaysScroll: true,
|
||||||
|
scrollbar: {
|
||||||
|
ch: " ",
|
||||||
|
inverse: true
|
||||||
|
},
|
||||||
|
keys: false,
|
||||||
|
vi: false,
|
||||||
|
mouse: true,
|
||||||
|
data: [["Name", "Size"]]
|
||||||
|
});
|
||||||
|
|
||||||
|
this.screen.append(this.assets);
|
||||||
|
};
|
||||||
|
|
||||||
|
Dashboard.prototype.layoutStatus = function() {
|
||||||
|
|
||||||
|
this.wrapper = blessed.layout({
|
||||||
|
width: "25%",
|
||||||
|
height: "42%",
|
||||||
|
top: "0%",
|
||||||
|
left: "75%",
|
||||||
|
layout: "grid"
|
||||||
|
});
|
||||||
|
|
||||||
|
this.status = blessed.box({
|
||||||
|
parent: this.wrapper,
|
||||||
|
label: "Environment",
|
||||||
|
tags: true,
|
||||||
|
padding: {
|
||||||
|
left: 1,
|
||||||
|
},
|
||||||
|
width: "100%",
|
||||||
|
height: "25%",
|
||||||
|
valign: "middle",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.operations = blessed.box({
|
||||||
|
parent: this.wrapper,
|
||||||
|
label: "Status",
|
||||||
|
tags: true,
|
||||||
|
padding: {
|
||||||
|
left: 1,
|
||||||
|
},
|
||||||
|
width: "100%",
|
||||||
|
height: "25%",
|
||||||
|
valign: "middle",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.progress = blessed.box({
|
||||||
|
parent: this.wrapper,
|
||||||
|
label: "Available Services",
|
||||||
|
tags: true,
|
||||||
|
padding: this.minimal ? {
|
||||||
|
left: 1,
|
||||||
|
} : 1,
|
||||||
|
width: "100%",
|
||||||
|
height: "58%",
|
||||||
|
valign: "middle",
|
||||||
|
border: {
|
||||||
|
type: "line",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: -1,
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.screen.append(this.wrapper);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Dashboard.prototype.layoutCmd = function() {
|
||||||
|
this.consoleBox = blessed.box({
|
||||||
|
label: 'Console',
|
||||||
|
tags: true,
|
||||||
|
padding: 0,
|
||||||
|
width: '100%',
|
||||||
|
height: '6%',
|
||||||
|
left: '0%',
|
||||||
|
top: '95%',
|
||||||
|
border: {
|
||||||
|
type: 'line',
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fg: 'black',
|
||||||
|
border: {
|
||||||
|
fg: this.color,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.input = blessed.textbox({
|
||||||
|
parent: this.consoleBox,
|
||||||
|
name: 'input',
|
||||||
|
input: true,
|
||||||
|
keys: false,
|
||||||
|
top: 0,
|
||||||
|
left: 1,
|
||||||
|
height: '50%',
|
||||||
|
width: '100%-2',
|
||||||
|
inputOnFocus: true,
|
||||||
|
style: {
|
||||||
|
fg: 'green',
|
||||||
|
bg: 'black',
|
||||||
|
focus: {
|
||||||
|
bg: 'black',
|
||||||
|
fg: 'green'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.input.on('submit', function(data) {
|
||||||
|
if (data !== '') {
|
||||||
|
self.logText.log('console> ' + data);
|
||||||
|
}
|
||||||
|
if (data === 'quit') {
|
||||||
|
exit();
|
||||||
|
};
|
||||||
|
self.input.clearValue();
|
||||||
|
self.input.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.screen.append(this.consoleBox);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Dashboard;
|
@ -6,13 +6,15 @@ var Pipeline = function(options) {
|
|||||||
this.buildDir = options.buildDir;
|
this.buildDir = options.buildDir;
|
||||||
this.contractsFiles = options.contractsFiles;
|
this.contractsFiles = options.contractsFiles;
|
||||||
this.assetFiles = options.assetFiles;
|
this.assetFiles = options.assetFiles;
|
||||||
|
this.logger = options.logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
Pipeline.prototype.build = function(abi) {
|
Pipeline.prototype.build = function(abi) {
|
||||||
|
var self = this;
|
||||||
for(var targetFile in this.assetFiles) {
|
for(var targetFile in this.assetFiles) {
|
||||||
|
|
||||||
var content = this.assetFiles[targetFile].map(function(file) {
|
var content = this.assetFiles[targetFile].map(function(file) {
|
||||||
console.log("reading " + file.filename);
|
self.logger.info("reading " + file.filename);
|
||||||
if (file.filename === 'embark.js') {
|
if (file.filename === 'embark.js') {
|
||||||
return file.content + "\n" + abi;
|
return file.content + "\n" + abi;
|
||||||
} else {
|
} else {
|
||||||
@ -21,7 +23,7 @@ Pipeline.prototype.build = function(abi) {
|
|||||||
}).join("\n");
|
}).join("\n");
|
||||||
|
|
||||||
var dir = targetFile.split('/').slice(0, -1).join('/');
|
var dir = targetFile.split('/').slice(0, -1).join('/');
|
||||||
console.log("creating dir " + this.buildDir + dir);
|
self.logger.info("creating dir " + this.buildDir + dir);
|
||||||
mkdirp.sync(this.buildDir + dir);
|
mkdirp.sync(this.buildDir + dir);
|
||||||
|
|
||||||
fs.writeFileSync(this.buildDir + targetFile, content);
|
fs.writeFileSync(this.buildDir + targetFile, content);
|
||||||
|
@ -5,6 +5,7 @@ var serveStatic = require('serve-static');
|
|||||||
var Server = function(options) {
|
var Server = function(options) {
|
||||||
this.dist = options.dist || 'dist/';
|
this.dist = options.dist || 'dist/';
|
||||||
this.port = options.port || 8000;
|
this.port = options.port || 8000;
|
||||||
|
this.logger = options.logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype.start = function(callback) {
|
Server.prototype.start = function(callback) {
|
||||||
@ -14,7 +15,7 @@ Server.prototype.start = function(callback) {
|
|||||||
serve(req, res, finalhandler(req, res));
|
serve(req, res, finalhandler(req, res));
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(("listening on port " + this.port).underline.green);
|
this.logger.info(("listening on port " + this.port).underline.green);
|
||||||
server.listen(this.port) ;
|
server.listen(this.port) ;
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
14
lib/watch.js
14
lib/watch.js
@ -3,7 +3,7 @@ var fs = require('fs');
|
|||||||
var chokidar = require('chokidar');
|
var chokidar = require('chokidar');
|
||||||
|
|
||||||
var Watch = function(options) {
|
var Watch = function(options) {
|
||||||
this.options = options;
|
this.logger = options.logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
Watch.prototype.start = function() {
|
Watch.prototype.start = function() {
|
||||||
@ -17,7 +17,7 @@ Watch.prototype.start = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add callback to ready
|
// TODO: add callback to ready
|
||||||
console.log(filesToWatch);
|
this.logger.trace(filesToWatch);
|
||||||
var watcher = chokidar.watch(filesToWatch, {
|
var watcher = chokidar.watch(filesToWatch, {
|
||||||
ignored: /[\/\\]\./,
|
ignored: /[\/\\]\./,
|
||||||
persistent: true,
|
persistent: true,
|
||||||
@ -25,11 +25,11 @@ Watch.prototype.start = function() {
|
|||||||
followSymlinks: true
|
followSymlinks: true
|
||||||
});
|
});
|
||||||
watcher
|
watcher
|
||||||
.on('add', path => console.log(`File ${path} has been added`))
|
.on('add', path => this.logger.info(`File ${path} has been added`))
|
||||||
.on('change', path => console.log(`File ${path} has been changed`))
|
.on('change', path => this.logger.info(`File ${path} has been changed`))
|
||||||
.on('unlink', path => console.log(`File ${path} has been removed`))
|
.on('unlink', path => this.logger.info(`File ${path} has been removed`))
|
||||||
.on('ready', () => console.log('ready to watch changes'));
|
.on('ready', () => this.logger.info('ready to watch changes'));
|
||||||
console.log("done!");
|
this.logger.info("done!");
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Watch;
|
module.exports = Watch;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.0.1",
|
"async": "^2.0.1",
|
||||||
"bignumber.js": "debris/bignumber.js#master",
|
"bignumber.js": "debris/bignumber.js#master",
|
||||||
|
"blessed": "^0.1.81",
|
||||||
"bluebird": "^3.4.1",
|
"bluebird": "^3.4.1",
|
||||||
"chokidar": "^1.6.0",
|
"chokidar": "^1.6.0",
|
||||||
"colors": "^1.1.2",
|
"colors": "^1.1.2",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user