Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 30, 2020
1 parent 542f819 commit eca5539
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
28 changes: 14 additions & 14 deletions bin/config.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
'use strict'

var pkg = require('../package.json')
var FIVE_DAYS = 1000 * 60 * 60 * 24 * 5
const pkg = require('../package.json')
const FIVE_DAYS = 1000 * 60 * 60 * 24 * 5

var Configstore = require('configstore')
var configName = 'update-notifier-' + pkg.name
var config = new Configstore(configName, { nodeVersions: [] })
var fetchCheckInterval = process.env.NODENGINE_INTERVAL || FIVE_DAYS
const Configstore = require('configstore')
const configName = 'update-notifier-' + pkg.name
const config = new Configstore(configName, { nodeVersions: [] })
const fetchCheckInterval = process.env.NODENGINE_INTERVAL || FIVE_DAYS

var waterfall = require('async').waterfall
var fetch = require('./fetch')
const waterfall = require('async').waterfall
const fetch = require('./fetch')

function loadConfig (cb) {
var tasks = [
const tasks = [
function checkCache (next) {
var currentNodeVersions = config.get('nodeVersions')
var lastFetchCheck = config.get('lastFetchCheck')
var hasVersions = currentNodeVersions.length
var now = Date.now()
var isCacheValid = now - lastFetchCheck < fetchCheckInterval
const currentNodeVersions = config.get('nodeVersions')
const lastFetchCheck = config.get('lastFetchCheck')
const hasVersions = currentNodeVersions.length
const now = Date.now()
const isCacheValid = now - lastFetchCheck < fetchCheckInterval

if (hasVersions && isCacheValid) return next(null, currentNodeVersions)

Expand Down
6 changes: 3 additions & 3 deletions bin/fetch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

var get = require('simple-get')
var URL = 'https://semver.io/node/versions'
const get = require('simple-get')
const URL = 'https://semver.io/node/versions'

function fetch (cb) {
get.concat(URL, function (err, res, data) {
if (err) return cb(err)
var nodeVersions = data.toString().split('\n')
const nodeVersions = data.toString().split('\n')
return cb(null, nodeVersions)
})
}
Expand Down
10 changes: 5 additions & 5 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

'use strict'

var path = require('path')
var fs = require('fs')
const path = require('path')
const fs = require('fs')

require('meow')({
pkg: require(path.resolve(__dirname, '../package.json')),
help: fs.readFileSync(path.resolve(__dirname, './help.txt'), 'utf8')
})

var pkgPath = path.resolve('package.json')
var pkg = fs.existsSync(pkgPath) ? require(pkgPath) : {}
var nodeVersion = pkg.engines && pkg.engines.node
const pkgPath = path.resolve('package.json')
const pkg = fs.existsSync(pkgPath) ? require(pkgPath) : {}
const nodeVersion = pkg.engines && pkg.engines.node

!nodeVersion ? process.exit() : require('./switch')(nodeVersion)
16 changes: 8 additions & 8 deletions bin/switch.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use strict'

var waterfall = require('async').waterfall
var semver = require('semver')
const waterfall = require('async').waterfall
const semver = require('semver')

function _switch (nodeVersion) {
var createSwitcher = require('./switcher')
var config = require('./config')
const createSwitcher = require('./switcher')
const config = require('./config')

var tasks = [
const tasks = [
function loadConfig (next) {
return config(next)
},
function getSwitcher (versions, next) {
var currentVersion = process.versions.node
var maxSatisfyVersion = semver.maxSatisfying(versions, nodeVersion)
var switcher = createSwitcher(maxSatisfyVersion, currentVersion)
const currentVersion = process.versions.node
const maxSatisfyVersion = semver.maxSatisfying(versions, nodeVersion)
const switcher = createSwitcher(maxSatisfyVersion, currentVersion)

switcher.getBin(function (err, bin) {
return next(err, switcher, bin)
Expand Down
18 changes: 9 additions & 9 deletions bin/switcher.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var spawn = require('child_process').spawn
var doWhilst = require('async').doWhilst
var which = require('./which')
const spawn = require('child_process').spawn
const doWhilst = require('async').doWhilst
const which = require('./which')

function nvmCommand (maxSatisfyVersion, currentVersion) {
var cmd = ''
let cmd = ''
cmd += 'nvm install '
cmd += maxSatisfyVersion
if (currentVersion !== maxSatisfyVersion) {
Expand All @@ -16,7 +16,7 @@ function nvmCommand (maxSatisfyVersion, currentVersion) {
}

function createSwitcher (maxSatisfyVersion, currentVersion) {
var binaries = {
const binaries = {
n: {
cmd: 'n',
args: [maxSatisfyVersion]
Expand All @@ -29,12 +29,12 @@ function createSwitcher (maxSatisfyVersion, currentVersion) {

return {
getBin: function (cb) {
var binariesNames = Object.keys(binaries)
var index = 0
var bin
const binariesNames = Object.keys(binaries)
let index = 0
let bin

function getBin (cb) {
var binName = binariesNames[index++]
const binName = binariesNames[index++]
which(binName, function (err) {
if (!err) bin = binName
return cb()
Expand Down
6 changes: 3 additions & 3 deletions bin/which.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

var _which = require('which')
var NVM_DIR = process.env.NVM_DIR
const _which = require('which')
const NVM_DIR = process.env.NVM_DIR

function which (bin, cb) {
var binaries = {
const binaries = {
n: function () { return _which(bin, cb) },
nvm: function () { return cb(NVM_DIR ? null : 'nope') }
}
Expand Down

0 comments on commit eca5539

Please sign in to comment.