<commit_before>var fs = require('fs'),
path = require('path'),
log = require('./display.js').log,
root = process.env.NECO_ROOT,
pkgDir = path.join(__dirname, '..'),
ecosystem = process.env.NODE_ECOSYSTEM,
recordFile = path.join(root, '.neco', 'record.json'),
pkgActivateFile = path.join(pkgDir, 'shell/activate.sh'),
globalActivateFile = path.join(root, '.neco', 'activate.sh'),
findlongestID = require('./assistant.js').findlongestID;  

var message, warning, error, suggestion, example;

exports.envReady = function(config, next) {
  var root = config.root, ecosystem = config.ecosystem, cmd = config.cmd;
  if (root === undefined || ecosystem !== undefined) {
    if (root === undefined) {
      message = 'It\'s seems that you have not setup NECO_ROOT environment variable!';
      suggestion = 'add \'export NECO_ROOT=<path>\' into your shell config file.';
      log('message', message, suggestion);
    } else if (root !== undefined && ecosystem !== undefined) {
      if (cmd === 'create') {
        warning = 'It\'s seems that you are alreay in a node ecosystem.';
        suggestion = 'First, deactivate existing ecosystem, then create new one.';
        example = 'neco_deactivate'; 
        log('warning', warning, suggestion, example);
      } else {
        next(config);
      }
    }
  } else {
    next(config);
  }
};

exports.rootReady = function(config, next) {
  var rootDir = path.join(config.root, '.neco');
  path.exists(rootDir, function(exists) {
    if (!exists) {
      fs.mkdir(rootDir, mode=0777, function(err) {
        if (err) {throw err;}
        next(config);
      });
    } else {
      next(config);
    }
  });
};

exports.recordReady = function(config, next) {
  var cmd = config.cmd, recordFile = config.recordFile;
  path.exists(recordFile, function(exists) {
    if (!exists) {
      if (cmd !== 'create') {
        message = 'You have not create any node ecosystem yet.';
        suggestion = 'Use create command to create first one!';
        example = 'nc create <id> [stable, latest, node-version]';
        log('message', message, suggestion, example);
      } else {
        next(exists, config);
      }
    } else {
      config.idLenStandard = findlongestID(config); 
      next(exists, config);
    }
  });
};

exports.activateReady = function(config, next) {
  var globalActivateFile = config.globalActivateFile,
  pkgActivateFile = config.pkgActivateFile;
  path.exists(globalActivateFile, function(exists) {
    if (!exists) {
      fs.readFile(pkgActivateFile, 'utf8', function(err, data) {
        if (err) {throw err;}
        fs.writeFile(globalActivateFile, data, 'utf8', function(err) {
          if (err) {throw err;}
          next(config);
        });
      });
    } else {
      next(config);
    }
  });
};
<commit_msg>check the number of ecosysem in recordReady method<commit_after>var fs = require('fs'),
path = require('path'),
log = require('./display.js').log,
root = process.env.NECO_ROOT,
pkgDir = path.join(__dirname, '..'),
ecosystem = process.env.NODE_ECOSYSTEM,
recordFile = path.join(root, '.neco', 'record.json'),
pkgActivateFile = path.join(pkgDir, 'shell/activate.sh'),
globalActivateFile = path.join(root, '.neco', 'activate.sh'),
findlongestID = require('./assistant.js').findlongestID;  

var message, warning, error, suggestion, example;

exports.envReady = function(config, next) {
  var root = config.root, ecosystem = config.ecosystem, cmd = config.cmd;
  if (root === undefined || ecosystem !== undefined) {
    if (root === undefined) {
      message = 'It\'s seems that you have not setup NECO_ROOT environment variable!';
      suggestion = 'add \'export NECO_ROOT=<path>\' into your shell config file.';
      log('message', message, suggestion);
    } else if (root !== undefined && ecosystem !== undefined) {
      if (cmd === 'create') {
        warning = 'It\'s seems that you are alreay in a node ecosystem.';
        suggestion = 'First, deactivate existing ecosystem, then create new one.';
        example = 'neco_deactivate'; 
        log('warning', warning, suggestion, example);
      } else {
        next(config);
      }
    }
  } else {
    next(config);
  }
};

exports.rootReady = function(config, next) {
  var rootDir = path.join(config.root, '.neco');
  path.exists(rootDir, function(exists) {
    if (!exists) {
      fs.mkdir(rootDir, mode=0777, function(err) {
        if (err) {throw err;}
        next(config);
      });
    } else {
      next(config);
    }
  });
};

exports.recordReady = function(config, next) {
  var cmd = config.cmd, recordFile = config.recordFile,
  ecosystems;
  path.exists(recordFile, function(exists) {
    if (!exists) {
      if (cmd !== 'create') {
        message = 'You have not create any node ecosystem yet.';
        suggestion = 'Use create command to create first one!';
        example = 'nc create <id> [stable, latest, node-version]';
        log('message', message, suggestion, example);
      } else {
        next(exists, config);
      }
    } else {
      ecosystems = JSON.parse(fs.readFileSync(recordFile, 'utf8')).ecosystems;
      if (ecosystems.length === 0) {
        message = 'You have not create any node ecosystem yet.';
        suggestion = 'Use create command to create first one!';
        example = 'nc create <id> [stable, latest, node-version]';
        log('message', message, suggestion, example);     
      } else {
        config.idLenStandard = findlongestID(config); 
        next(exists, config);
      }
    }
  });
};

exports.activateReady = function(config, next) {
  var globalActivateFile = config.globalActivateFile,
  pkgActivateFile = config.pkgActivateFile;
  path.exists(globalActivateFile, function(exists) {
    if (!exists) {
      fs.readFile(pkgActivateFile, 'utf8', function(err, data) {
        if (err) {throw err;}
        fs.writeFile(globalActivateFile, data, 'utf8', function(err) {
          if (err) {throw err;}
          next(config);
        });
      });
    } else {
      next(config);
    }
  });
};

{'fraction_non_alphanumeric': 0.14942719574962643, 'fraction_numerical': 0.002324423044994189, 'mean_word_length': 3.00531914893617, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '6463370', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1841, 'n_words': 473}