refactor: downlevel, use strict
This commit is contained in:
parent
16c7708dd7
commit
30bcddd34d
@ -18,7 +18,7 @@
|
||||
"quotmark": "single",
|
||||
"regexp": true,
|
||||
"smarttabs": false,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user