<commit_before>var utils = require('shipit-utils');
var chalk = require('chalk');
var sprintf = require('sprintf-js').sprintf;
var Bluebird = require('bluebird');
var argv = require('yargs').argv;

/**
 * cmd task allows access to any nvm cli command
 */

module.exports = function (gruntOrShipit) {
  utils.registerTask(gruntOrShipit, 'nvm:cmd', task);

  function task() {
    var shipit = utils.getShipit(gruntOrShipit);

    function cmd(remote) {

      if(!remote) {
        throw new Error(
          shipit.log(
            chalk.red('shipit.config.nvm.remote is', remote),
            chalk.gray('try running nvm:init before nvm:cmd')
          )
        );
      }

      var method = remote ? 'remote' : 'local';
      var cdPath = remote ? shipit.releasePath || shipit.currentPath : shipit.config.workspace;

      if(!cdPath) {
        var msg = remote ? 'Please specify a deploy to path (shipit.config.deployTo)' : 'Please specify a workspace (shipit.config.workspace)';
        throw new Error(
          shipit.log(chalk.red(msg))
        );
      }

      if(!argv.cmd) {
        throw new Error(
          shipit.log(
            chalk.red('Please specify a nvm command eg'),
            chalk.gray('shipit staging nvm:cmd'),
            chalk.white('--cmd "install 0.10.37"')
          )
        );
      }

      return shipit[method](
        sprintf('cd %s && nvm %s', cdPath, argv.cmd)
      );

    }

    shipit.log('Running - nvm ' + argv.cmd);

    return cmd(shipit.config.nvm.remote)
    .then(function () {
      shipit.log(chalk.green('Complete - nvm ' + argv.cmd));
    })
    .catch(function (e) {
      shipit.log(e);
    });<commit_msg>ensure shipit-nvm is inited before running cmd task<commit_after>var utils = require('shipit-utils');
var chalk = require('chalk');
var sprintf = require('sprintf-js').sprintf;
var Bluebird = require('bluebird');
var argv = require('yargs').argv;

/**
 * cmd task allows access to any nvm cli command
 */

module.exports = function (gruntOrShipit) {
  utils.registerTask(gruntOrShipit, 'nvm:cmd', task);

  function task() {
    var shipit = utils.getShipit(gruntOrShipit);

    function cmd(remote) {
      shipit.log("Remote = "+remote);

      var method = remote ? 'remote' : 'local';
      var cdPath = remote ? shipit.releasePath || shipit.currentPath : shipit.config.workspace;

      shipit.log(cdPath);
      if(!cdPath) {
        var msg = remote ? 'Please specify a deploy to path (shipit.config.deployTo).' : 'Please specify a workspace (shipit.config.workspace)';
        throw new Error(
          shipit.log(chalk.red(msg))
        );
      }

      if(!argv.cmd) {
        throw new Error(
          shipit.log(
            chalk.red('Please specify a nvm command eg'),
            chalk.gray('shipit staging nvm:cmd'),
            chalk.white('--cmd "install 0.10.37"')
          )
        );
      }

      return shipit[method](
        sprintf('cd %s && nvm %s', cdPath, argv.cmd)
      );

    }

    shipit.log('Running - nvm ' + argv.cmd);

    if(shipit.nvm_inited) {

      return cmd(shipit.config.nvm.remote)
      .then(function () {
        shipit.log(chalk.green('Complete - nvm ' + argv.cmd));
      })
      .catch(function (e) {
        shipit.log(chalk.red(e));
      });

    }else {
      throw new Error(
        shipit.log(
          chalk.gray('try running nvm:init before nvm:cmd')
        )
      );
    }
{'fraction_non_alphanumeric': 0.14427860696517414, 'fraction_numerical': 0.0029265437518290896, 'mean_word_length': 2.2739463601532566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5853873', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1110, 'n_words': 244}