From 30bcddd34deafcd8b62d74a17e1d632b39022121 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Wed, 9 Aug 2017 12:49:15 -0400 Subject: [PATCH] refactor: downlevel, use strict --- .jshintrc | 2 +- lib/scaffold/default-config.js | 18 ++++++++++-------- lib/scaffold/start.js | 4 +++- lib/services/p2p/index.js | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.jshintrc b/.jshintrc index 7cf0813b..d735c345 100644 --- a/.jshintrc +++ b/.jshintrc @@ -18,7 +18,7 @@ "quotmark": "single", "regexp": true, "smarttabs": false, - "strict": false, + "strict": true, "trailing": true, "undef": true, "unused": true, diff --git a/lib/scaffold/default-config.js b/lib/scaffold/default-config.js index 17d3a68b..c6b833aa 100644 --- a/lib/scaffold/default-config.js +++ b/lib/scaffold/default-config.js @@ -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]); @@ -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 @@ -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', @@ -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, diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index f3384283..419608a7 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -1,3 +1,5 @@ +'use strict'; + var path = require('path'); var BitcoreNode = require('../node'); var index = require('../'); @@ -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) { diff --git a/lib/services/p2p/index.js b/lib/services/p2p/index.js index 68a50bcf..183ffb94 100644 --- a/lib/services/p2p/index.js +++ b/lib/services/p2p/index.js @@ -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