const packageJson = require('../../package.json')
const latestVersion = require('latest-version')
const semverDiff = require('semver-diff')
const _ = require('lodash')
const db = require('./db.js')
const configUtil = require('./config')

const ONE_DAY = 1000 * 60 * 60 * 24

const version = {
  updateAvailable: false,
  updateType: null,
  current: packageJson.version,
  latest: null
}

function checkForUpdate() {
  return configUtil
    .getHelper(db)
    .then(config => {
      if (config.get('disableUpdateCheck')) {
        return
      }
      return latestVersion(packageJson.name).then(npmVersion => {
        version.latest = npmVersion
        const difference = semverDiff(version.current, npmVersion)
        if (difference) {
          version.updateAvailable = true
          version.updateType = difference
          console.log('\n' + '='.repeat(70))
          console.log('update available (%s)', version.updateType)
          console.log(
            'current version: %s      latest: %s',
            version.curent,
            version.latest
          )
          console.log("run 'npm i -g " + packageJson.name + "' to update.")
          console.log('='.repeat(70) + '\n')
        }
      })
    })
    .catch(error => {
      console.log(error)
    })
}

setInterval(checkForUpdate, ONE_DAY)
setTimeout(checkForUpdate, 5000)

module.exports = function() {
  return _.clone(version)
}

@@ -137,36 +137,8 @@
 f')%0A
-const _ = require('lodash')%0A
 cons
@@ -163,16 +163,16 @@
 db.js')%0A
+
 const co
@@ -354,16 +354,383 @@
 null%0A%7D%0A%0A
+function logUpdateAvailable(version) %7B%0A  console.log(%60%0A  ===================================================================%0A  Update available ($%7Bversion.updateType%7D)%0A  Current version: $%7Bversion.current%7D%0A  Latest  version: $%7Bversion.latest%7D%0A%0A  run npm i -g $%7BpackageJson.name%7D to update%0A  ===================================================================%0A  %60)%0A%7D%0A%0A
 function
@@ -1171,82 +1171,26 @@
     
-console.log('%5Cn' + '='.repeat(70))%0A          console.log('u
+logU
 pdate
- a
+A
 vailable
  (%25s
@@ -1189,296 +1189,16 @@
 able
- (%25s)', version.updateType)%0A          console.log(%0A            'current version: %25s      latest: %25s',%0A            version.curent,%0A            version.latest%0A          )%0A          console.log(%22run 'npm i -g %22 + packageJson.name + %22' to update.%22)%0A          console.log('='.repeat(70) + '%5Cn'
+(version
 )%0A  
@@ -1392,16 +1392,26 @@
 urn 
-_.clone(
+Object.assign(%7B%7D, 
 vers

Tidy up get-version