'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
  return require('child_process').execSync(cmd).toString().trim()
}

const versionRequirements = [
  {
    name: 'node',
    currentVersion: semver.clean(process.version),
    versionRequirement: packageConfig.engines.node
  }
]

if (shell.which('npm')) {
  versionRequirements.push({
    name: 'npm',
    currentVersion: exec('npm --version'),
    versionRequirement: packageConfig.engines.npm
  })
}

module.exports = function () {
  const warnings = []
  for (let i = 0; i < versionRequirements.length; i++) {
    const mod = versionRequirements[i]
    if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
      warnings.push(mod.name + ': ' +
        chalk.red(mod.currentVersion) + ' should be ' +
        chalk.green(mod.versionRequirement)
      )
    }
  }

  if (warnings.length) {
    console.log('')
    console.log(chalk.yellow('To use this template, you must update following to modules:'))
    console.log()
    for (let i = 0; i < warnings.length; i++) {
      const warning = warnings[i]
      console.log('  ' + warning)
    }
    console.log()
    process.exit(1)
  }
}

@@ -74,90 +74,8 @@
 r')%0A
-const packageConfig = require('../package.json')%0Aconst shell = require('shelljs')%0A
 func
@@ -165,341 +165,8 @@
 %0A%7D%0A%0A
-const versionRequirements = %5B%0A  %7B%0A    name: 'node',%0A    currentVersion: semver.clean(process.version),%0A    versionRequirement: packageConfig.engines.node%0A  %7D%0A%5D%0A%0Aif (shell.which('npm')) %7B%0A  versionRequirements.push(%7B%0A    name: 'npm',%0A    currentVersion: exec('npm --version'),%0A    versionRequirement: packageConfig.engines.npm%0A  %7D)%0A%7D%0A
 %0Amod

make it better