fix linter complaints

This commit is contained in:
Todd Baur 2017-03-30 02:18:00 +09:00
parent 4ae5757bae
commit e3b9c01205
5 changed files with 42 additions and 38 deletions

View File

@ -1,11 +1,11 @@
var program = require('commander');
var colors = require('colors');
var shelljs = require('shelljs');
var promptly = require('promptly');
var path = require('path');
var Embark = require('../lib/index');
let program = require('commander');
let colors = require('colors');
let shelljs = require('shelljs');
let promptly = require('promptly');
let path = require('path');
let Embark = require('../lib/index');
var Cmd = function() {
let Cmd = function() {
program.version(Embark.version);
};
@ -31,7 +31,7 @@ Cmd.prototype.process = function(args) {
Cmd.prototype.newApp = function(name) {
var validateName = function (value) {
let validateName = function (value) {
try {
if(value.match(/^[a-zA-Z\s\-]+$/)) return value;
} catch (e) {
@ -44,7 +44,7 @@ Cmd.prototype.newApp = function(name) {
.description('new application')
.action(function (name) {
if (name === undefined) {
var parentDirectory = path.dirname(__dirname).split("/").pop();
let parentDirectory = path.dirname(__dirname).split("/").pop();
return promptly.prompt("Name your app (default is " + parentDirectory + "):", {
default: parentDirectory,
validator: validateName

View File

@ -1,12 +1,12 @@
var colors = require('colors');
var shelljs = require('shelljs');
let colors = require('colors');
let shelljs = require('shelljs');
var fs = require('../../core/fs.js');
let fs = require('../../core/fs.js');
var GethCommands = require('./geth_commands.js');
let GethCommands = require('./geth_commands.js');
/*eslint complexity: ["error", 22]*/
var Blockchain = function(options) {
let Blockchain = function(options) {
this.blockchainConfig = options.blockchainConfig;
this.env = options.env || 'development';
this.client = options.client;
@ -41,20 +41,20 @@ Blockchain.prototype.runCommand = function(cmd) {
};
Blockchain.prototype.run = function() {
var self = this;
let self = this;
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
var address = this.initChainAndGetAddress();
let address = this.initChainAndGetAddress();
this.client.mainCommand(address, function(cmd) {
self.runCommand(cmd);
});
};
Blockchain.prototype.initChainAndGetAddress = function() {
var address = null, result;
let address = null, result;
// ensure datadir exists, bypassing the interactive liabilities prompt.
this.datadir = '.embark/' + this.env + '/datadir';
@ -82,7 +82,7 @@ Blockchain.prototype.initChainAndGetAddress = function() {
return address;
};
var BlockchainClient = function(blockchainConfig, client, env) {
let BlockchainClient = function(blockchainConfig, client, env) {
if (client === 'geth') {
return new Blockchain({blockchainConfig: blockchainConfig, client: GethCommands, env: env});
} else {

View File

@ -1,22 +1,21 @@
/*jshint esversion: 6, loopfunc: true */
var async = require('../utils/async_extend.js');
var SolcW = require('./solcW.js');
let async = require('../utils/async_extend.js');
let SolcW = require('./solcW.js');
var Compiler = function(options) {
let Compiler = function(options) {
this.plugins = options.plugins;
this.logger = options.logger;
};
Compiler.prototype.compile_contracts = function(contractFiles, cb) {
var self = this;
var available_compilers = {
let available_compilers = {
//".se": this.compile_serpent
".sol": this.compile_solidity.bind(this)
};
if (this.plugins) {
var compilerPlugins = this.plugins.getPluginsFor('compilers');
let compilerPlugins = this.plugins.getPluginsFor('compilers');
if (compilerPlugins.length > 0) {
compilerPlugins.forEach(function(plugin) {
plugin.compilers.forEach(function(compilerObject) {
@ -26,12 +25,12 @@ Compiler.prototype.compile_contracts = function(contractFiles, cb) {
}
}
var compiledObject = {};
let compiledObject = {};
async.eachObject(available_compilers,
function(extension, compiler, callback) {
// TODO: warn about files it doesn't know how to compile
var matchingFiles = contractFiles.filter(function(file) {
let matchingFiles = contractFiles.filter(function(file) {
return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension);
});
@ -47,14 +46,14 @@ Compiler.prototype.compile_contracts = function(contractFiles, cb) {
};
Compiler.prototype.compile_solidity = function(contractFiles, cb) {
var self = this;
var input = {};
var solcW;
let self = this;
let input = {};
let solcW;
async.waterfall([
function prepareInput(callback) {
for (var i = 0; i < contractFiles.length; i++){
for (let i = 0; i < contractFiles.length; i++){
// TODO: this depends on the config
var filename = contractFiles[i].filename.replace('app/contracts/','');
let filename = contractFiles[i].filename.replace('app/contracts/','');
input[filename] = contractFiles[i].content.toString();
}
callback();
@ -81,12 +80,12 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
});
},
function createCompiledObject(output, callback) {
var json = output.contracts;
let json = output.contracts;
compiled_object = {};
let compiled_object = {};
for (var className in json) {
var contract = json[className];
for (let className in json) {
let contract = json[className];
compiled_object[className] = {};
compiled_object[className].code = contract.bytecode;

View File

@ -2,6 +2,7 @@ let async = require('async');
let Deploy = require('./deploy.js');
let ContractsManager = require('./contracts.js');
const EventEmitter = require('events').EventEmitter;
let DeployManager = function(options) {
this.config = options.config;
@ -12,12 +13,15 @@ let DeployManager = function(options) {
this.chainConfig = (options.trackContracts !== false) ? this.config.chainTracker : false;
};
DeployManager.prototype = Object.create(EventEmitter.prototype);
DeployManager.prototype.deployContracts = function(done) {
let self = this;
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
self.logger.info("Blockchain component is disabled in the config".underline);
Embark.emit('blockchainDisabled', {});
this.emit('blockchainDisabled', {});
return done();
}
@ -71,7 +75,7 @@ DeployManager.prototype.deployContracts = function(done) {
env: self.config.env
});
deploy.deployAll(function() {
Embark.emit('contractsDeployed', contractsManager);
self.emit('contractsDeployed', contractsManager);
callback(null, contractsManager);
});
}

View File

@ -71,6 +71,7 @@
"-W058": true,
"-W014": true,
"expr": true,
"esversion": 6
"esversion": 6,
"unused": false
}
}