refactor: downlevel, use strict
This commit is contained in:
parent
16c7708dd7
commit
30bcddd34d
@ -18,7 +18,7 @@
|
|||||||
"quotmark": "single",
|
"quotmark": "single",
|
||||||
"regexp": true,
|
"regexp": true,
|
||||||
"smarttabs": false,
|
"smarttabs": false,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"trailing": true,
|
"trailing": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": true,
|
"unused": true,
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var mkdirp = require('mkdirp');
|
var mkdirp = require('mkdirp');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var package = require('../../package');
|
var packageJson = require('../../package');
|
||||||
|
|
||||||
function getMajorVersion(versionString) {
|
function getMajorVersion(versionString) {
|
||||||
return parseInt(versionString.split('.')[0]);
|
return parseInt(versionString.split('.')[0]);
|
||||||
@ -28,10 +30,10 @@ function getDefaultConfig(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(defaultConfigFile)) {
|
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
|
// 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 {
|
return {
|
||||||
path: defaultPath,
|
path: defaultPath,
|
||||||
config: currentConfig
|
config: currentConfig
|
||||||
@ -40,17 +42,17 @@ function getDefaultConfig(options) {
|
|||||||
|
|
||||||
console.log(`The configuration file at '${defaultConfigFile}' is incompatible with this version of Bitcore.`);
|
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
|
// bitcore-node.YYYY-MM-DD.UnixTimestamp.json
|
||||||
const backupFileName = `bitcore-node.${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getTime()}.json`;
|
var backupFileName = `bitcore-node.${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getTime()}.json`;
|
||||||
const backupFile = path.resolve(defaultPath, backupFileName);
|
var backupFile = path.resolve(defaultPath, backupFileName);
|
||||||
fs.renameSync(defaultConfigFile, backupFile);
|
fs.renameSync(defaultConfigFile, backupFile);
|
||||||
console.log(`The previous configuration file has been moved to: ${backupFile}.`);
|
console.log(`The previous configuration file has been moved to: ${backupFile}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Creating a new configuration file at: ${defaultConfigFile}.`);
|
console.log(`Creating a new configuration file at: ${defaultConfigFile}.`);
|
||||||
|
|
||||||
const defaultServices = [
|
var defaultServices = [
|
||||||
'address',
|
'address',
|
||||||
'block',
|
'block',
|
||||||
'db',
|
'db',
|
||||||
@ -70,7 +72,7 @@ function getDefaultConfig(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
version: package.version,
|
version: packageJson.version,
|
||||||
network: 'livenet',
|
network: 'livenet',
|
||||||
port: 3001,
|
port: 3001,
|
||||||
services: options.additionalServices ? defaultServices.concat(options.additionalServices) : defaultServices,
|
services: options.additionalServices ? defaultServices.concat(options.additionalServices) : defaultServices,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var BitcoreNode = require('../node');
|
var BitcoreNode = require('../node');
|
||||||
var index = require('../');
|
var index = require('../');
|
||||||
@ -84,7 +86,7 @@ function lookInRequirePathConfig(req, service) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lookInCwd(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 {
|
try {
|
||||||
return req(process.cwd() + '/' + location);
|
return req(process.cwd() + '/' + location);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@ -332,7 +332,7 @@ P2P.prototype._setResourceFilter = function(filter, resource) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
P2P.prototype._startBcoin = function() {
|
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({
|
this._bcoin = new Bcoin({
|
||||||
network: network,
|
network: network,
|
||||||
prefix: this.node.datadir
|
prefix: this.node.datadir
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user