refactor: pacify jshint
This commit is contained in:
parent
33d6559305
commit
16c7708dd7
@ -18,7 +18,7 @@
|
|||||||
"quotmark": "single",
|
"quotmark": "single",
|
||||||
"regexp": true,
|
"regexp": true,
|
||||||
"smarttabs": false,
|
"smarttabs": false,
|
||||||
"strict": true,
|
"strict": false,
|
||||||
"trailing": true,
|
"trailing": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"unused": true,
|
"unused": true,
|
||||||
@ -26,7 +26,7 @@
|
|||||||
"maxstatements": 25,
|
"maxstatements": 25,
|
||||||
"maxcomplexity": 10,
|
"maxcomplexity": 10,
|
||||||
"maxdepth": 4,
|
"maxdepth": 4,
|
||||||
"maxlen": 120,
|
"maxlen": 140,
|
||||||
"multistr": true,
|
"multistr": true,
|
||||||
"predef": [
|
"predef": [
|
||||||
"after",
|
"after",
|
||||||
|
|||||||
@ -3,6 +3,10 @@ var mkdirp = require('mkdirp');
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var package = require('../../package');
|
var package = require('../../package');
|
||||||
|
|
||||||
|
function getMajorVersion(versionString) {
|
||||||
|
return parseInt(versionString.split('.')[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return the path and default bitcore-node configuration. It will search for the
|
* Will return the path and default bitcore-node configuration. It will search for the
|
||||||
* configuration file in the "~/.bitcore" directory, and if it doesn't exist, it will create one
|
* configuration file in the "~/.bitcore" directory, and if it doesn't exist, it will create one
|
||||||
@ -25,16 +29,12 @@ function getDefaultConfig(options) {
|
|||||||
|
|
||||||
if (fs.existsSync(defaultConfigFile)) {
|
if (fs.existsSync(defaultConfigFile)) {
|
||||||
const currentConfig = require(defaultConfigFile);
|
const currentConfig = require(defaultConfigFile);
|
||||||
|
|
||||||
function getMajorVersion(versionString) {
|
|
||||||
return parseInt(versionString.split('.')[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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(package.version) === getMajorVersion(currentConfig.version)) {
|
||||||
return {
|
return {
|
||||||
path: defaultPath,
|
path: defaultPath,
|
||||||
config: config
|
config: currentConfig
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ function getDefaultConfig(options) {
|
|||||||
|
|
||||||
const now = new Date();
|
const 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`;
|
const backupFileName = `bitcore-node.${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getTime()}.json`;
|
||||||
const backupFile = path.resolve(defaultPath, backupFileName);
|
const 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}.`);
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var BitcoreNode = require('../node');
|
var BitcoreNode = require('../node');
|
||||||
var index = require('../');
|
var index = require('../');
|
||||||
@ -86,11 +84,13 @@ function lookInRequirePathConfig(req, service) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lookInCwd(req, service) {
|
function lookInCwd(req, service) {
|
||||||
var location = service.config.cwdRequirePath ? service.config.cwdRequirePath : service.name
|
const 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) {
|
||||||
if(e.code !== 'MODULE_NOT_FOUND') log.error(e);
|
if(e.code !== 'MODULE_NOT_FOUND') {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
log.info('Checked the current working directory for service: ' + location);
|
log.info('Checked the current working directory for service: ' + location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +100,9 @@ function lookInBuiltInPath(req, service) {
|
|||||||
var serviceFile = path.resolve(__dirname, '../services/' + service.name);
|
var serviceFile = path.resolve(__dirname, '../services/' + service.name);
|
||||||
return req(serviceFile);
|
return req(serviceFile);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if(e.code !== 'MODULE_NOT_FOUND') log.error(e);
|
if(e.code !== 'MODULE_NOT_FOUND') {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
log.info('Checked the built-in path: lib/services, for service: ' + service.name);
|
log.info('Checked the built-in path: lib/services, for service: ' + service.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user