'use strict';

var util = require('runtime/lib/utils');
var runtime = require('runtime').get('gulp');

var whichGulp = runtime.config('which');
var env = runtime.config('env');

runtime.set(['-v', '--version'], function version(){

  //
  // always lazy
  // though it makes no sense here
  // since gulp itself its requiring them
  //
  var semver = require('semver');
  var chalk = util.colors;

  var cliPackage = env.cliPackage;
  var modulePackage = env.modulePackage;

  if( process.argv.indexOf(whichGulp) < 0 ){

    util.log('Working locally. Local gulp is ', modulePackage.version );

  } else if ( semver.gt(cliPackage.version, modulePackage.version) ) {

    util.log(chalk.red('Warning: gulp version mismatch:'));
    util.log(chalk.red('Global gulp is', cliPackage.version));
    util.log(chalk.red('Local gulp is', modulePackage.version));

  } else {
    util.log('CLI version', cliPackage.version);
    util.log('Local version', modulePackage.version);
  }

  runtime.prompt();
});

@@ -100,16 +100,49 @@
 );%0A%0Avar 
+env = runtime.config('env');%0Avar 
 whichGul
@@ -170,41 +170,8 @@
 hich
-');%0Avar env = runtime.config('env
 ');%0A

save env for version checks