<commit_before>/**
 *  Gulp hook for sails
 *
 */

module.exports = function (sails) {

  /**
   * Module dependencies
   */

  var Err = require('../../../../sails/errors'),
    path  = require('path'),
    ChildProcess = require('child_process');


  return {


    /**
     * Initialize this project's Grunt tasks
     * and execute the environment-specific gulpfile
     *
     */
    initialize: function (cb) {

      sails.log.verbose('Loading app Gulpfile...');

      // Start task depending on environment
      if(sails.config.environment === 'production'){
        return this.runTask('prod', cb);
      }

      this.runTask('default', cb);
    },


    /**
     * Fork Gulp child process
     *
     * @param {String} taskName - grunt task to run
     * @param {Function} cb - optional, fires when the Grunt task has been started (non-production) or finished (production)
     */
    runTask: function (taskName, cb_afterTaskStarted) {

      cb_afterTaskStarted = cb_afterTaskStarted || function () {};

      var environment = sails.config.environment;
      var pathToSails = path.resolve(__dirname, '../../../');

      // Only relevant in a development environment:
      // (unfortunately, cannot use sails.getBaseurl() because it is not calculatable yet)
      var baseurl = 'http://' + (sails.config.host || 'localhost') + ':' + sails.config.port;

      if (!taskName) {
        taskName = '';
      }

      // Fork Grunt child process
      var child = ChildProcess.fork(

        // cwd for child process
        path.join(pathToSails,'../gulp/bin/gulp.js'),

        // cmd args+opts for child process
        [
          taskName,
          '--pathToSails='+pathToSails,

          // Backwards compatibility for v0.9.x
          '--gdsrc='+ pathToSails + '/node_modules'
        ],

        // opts to pass to node's `child_process` logic
        {
          silent: true,
          stdio: 'pipe'
        }
      );


      var errorMsg = '';
      var stackTrace = '';

      // Log output as it comes in to the appropriate log channel
      child.stdout.on('data', function (consoleMsg) {

        // store all the output
        consoleMsg = consoleMsg.toString();<commit_msg>Fixed EADDRINUSE issue when running sails debug<commit_after>/**
 *  Gulp hook for sails
 *
 */

module.exports = function (sails) {

  /**
   * Module dependencies
   */

  var Err = require('../../../../sails/errors'),
    path  = require('path'),
    ChildProcess = require('child_process');


  return {


    /**
     * Initialize this project's Grunt tasks
     * and execute the environment-specific gulpfile
     *
     */
    initialize: function (cb) {

      sails.log.verbose('Loading app Gulpfile...');

      // Start task depending on environment
      if(sails.config.environment === 'production'){
        return this.runTask('prod', cb);
      }

      this.runTask('default', cb);
    },


    /**
     * Fork Gulp child process
     *
     * @param {String} taskName - grunt task to run
     * @param {Function} cb - optional, fires when the Grunt task has been started (non-production) or finished (production)
     */
    runTask: function (taskName, cb_afterTaskStarted) {

      cb_afterTaskStarted = cb_afterTaskStarted || function () {};

      var environment = sails.config.environment;
      var pathToSails = path.resolve(__dirname, '../../../');

      // Only relevant in a development environment:
      // (unfortunately, cannot use sails.getBaseurl() because it is not calculatable yet)
      var baseurl = 'http://' + (sails.config.host || 'localhost') + ':' + sails.config.port;

      if (!taskName) {
        taskName = '';
      }
      
      var execArgs = process.execArgv.slice(0);
      if(execArgs.indexOf('--debug') !== -1) {
        execArgs.splice(execArgs.indexOf('--debug'),1)
      }

      // Fork Grunt child process
      var child = ChildProcess.fork(

        // cwd for child process
        path.join(pathToSails,'../gulp/bin/gulp.js'),

        // cmd args+opts for child process
        [
          taskName,
          '--pathToSails='+pathToSails,

          // Backwards compatibility for v0.9.x
          '--gdsrc='+ pathToSails + '/node_modules'
        ],

        // opts to pass to node's `child_process` logic
        {
          silent: true,
          stdio: 'pipe',
          execArgv: execArgs
        }
      );


      var errorMsg = '';
      var stackTrace = '';

      // Log output as it comes in to the appropriate log channel
      child.stdout.on('data', function (consoleMsg) {

        // store all the output
        consoleMsg = consoleMsg.toString();
{'fraction_non_alphanumeric': 0.13390742734122713, 'fraction_numerical': 0.0015069967707212056, 'mean_word_length': 2.056578947368421, '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': '5785785', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1311, 'n_words': 359}