Skip to content

Commit

Permalink
refactor: downlevel, use strict
Browse files Browse the repository at this point in the history
  • Loading branch information
bitjson committed Aug 9, 2017
1 parent 16c7708 commit 30bcddd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"quotmark": "single",
"regexp": true,
"smarttabs": false,
"strict": false,
"strict": true,
"trailing": true,
"undef": true,
"unused": true,
Expand Down
18 changes: 10 additions & 8 deletions lib/scaffold/default-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

var path = require('path');
var mkdirp = require('mkdirp');
var fs = require('fs');
var package = require('../../package');
var packageJson = require('../../package');

function getMajorVersion(versionString) {
return parseInt(versionString.split('.')[0]);
Expand All @@ -28,10 +30,10 @@ function getDefaultConfig(options) {
}

if (fs.existsSync(defaultConfigFile)) {
const currentConfig = require(defaultConfigFile);
var currentConfig = require(defaultConfigFile);

// config must have a `version` field with major equal to package major version
if(currentConfig.version && getMajorVersion(package.version) === getMajorVersion(currentConfig.version)) {
if(currentConfig.version && getMajorVersion(packageJson.version) === getMajorVersion(currentConfig.version)) {
return {
path: defaultPath,
config: currentConfig
Expand All @@ -40,17 +42,17 @@ function getDefaultConfig(options) {

console.log(`The configuration file at '${defaultConfigFile}' is incompatible with this version of Bitcore.`);

const now = new Date();
var now = new Date();
// bitcore-node.YYYY-MM-DD.UnixTimestamp.json
const backupFileName = `bitcore-node.${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getTime()}.json`;
const backupFile = path.resolve(defaultPath, backupFileName);
var backupFileName = `bitcore-node.${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getTime()}.json`;
var backupFile = path.resolve(defaultPath, backupFileName);
fs.renameSync(defaultConfigFile, backupFile);
console.log(`The previous configuration file has been moved to: ${backupFile}.`);
}

console.log(`Creating a new configuration file at: ${defaultConfigFile}.`);

const defaultServices = [
var defaultServices = [
'address',
'block',
'db',
Expand All @@ -70,7 +72,7 @@ function getDefaultConfig(options) {
}

var defaultConfig = {
version: package.version,
version: packageJson.version,
network: 'livenet',
port: 3001,
services: options.additionalServices ? defaultServices.concat(options.additionalServices) : defaultServices,
Expand Down
4 changes: 3 additions & 1 deletion lib/scaffold/start.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var path = require('path');
var BitcoreNode = require('../node');
var index = require('../');
Expand Down Expand Up @@ -84,7 +86,7 @@ function lookInRequirePathConfig(req, service) {
}

function lookInCwd(req, service) {
const location = service.config.cwdRequirePath ? service.config.cwdRequirePath : service.name;
var location = service.config.cwdRequirePath ? service.config.cwdRequirePath : service.name;
try {
return req(process.cwd() + '/' + location);
} catch(e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/p2p/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ P2P.prototype._setResourceFilter = function(filter, resource) {
};

P2P.prototype._startBcoin = function() {
const network = ['livenet', 'live', 'main', 'mainnet'].indexOf(this.node.network) !== -1? 'main' : 'testnet';
var network = ['livenet', 'live', 'main', 'mainnet'].indexOf(this.node.network) !== -1? 'main' : 'testnet';
this._bcoin = new Bcoin({
network: network,
prefix: this.node.datadir
Expand Down

0 comments on commit 30bcddd

Please sign in to comment.