<commit_before>var AWS           = require('aws-sdk')
    , fs          = require('fs-extra')
    , path        = require('path')
    , async       = require('async')
    , chalk       = require('chalk')
    , ncp         = require('ncp')
    , gulp        = require('gulp')
    , zip         = require('gulp-zip')
    , gutil       = require('gulp-util')
    , task        = require('gulp-task')
    , pkg         = require(process.cwd() + '/package.json')
    ;

var data = {
  folderPath: null,   //e.g. ./functions/hello-world
  distPath: null,     //e.g. ./dist/hello-world
  environment: null   //e.g. staging
};

  
var clean = function(callback) {
  gutil.log('cleanup prep...');

  fs.remove(path.join(process.cwd(), 'dist'), function(err) {
    if (err) return callback(err);
    fs.ensureDir(data.distPath, function(err) { callback(err); });
  });
};

var npm = function(callback) {
  gutil.log('copying NPM modules for deployment...');
  ncp(
    path.join(process.cwd(), 'node_modules'),
    path.join(data.distPath, 'node_modules'),
    function(err) { callback(err); }
  );

};

// var envFile = function(callback) {
//   console.log('copying .env file...');
//   //use environment specific .env file if there is one
//   fs.exists(path.join(data.folderPath, '.env.' + data.environment), function(exists) {
//     var filename = "";
    
//     if (exists) {
//       filename = path.join(data.folderPath, '.env.' + data.environment);
//       console.log(chalk.yellow('using .env.' + data.environment + '...'), filename);
//       fs.createReadStream(filename).pipe(fs.createWriteStream(path.join(data.distPath, '.env.' + data.environment)));
//     }
//     else {
//       filename = path.join(data.folderPath, '.env');
//       console.log('copying file:', filename);
//       fs.createReadStream(filename).pipe(fs.createWriteStream(path.join(data.distPath, '.env')));
//     }
    
//     callback(null);
//   });
// };

var makeDist = function(callback) {
  gutil.log('creating dist folder...');

  //copy any file dependencies
  var devRoot = path.join(process.cwd(), 'dependencies');
  var runRoot = path.join(process.cwd(), 'node_modules/lambinator/dependencies');
  var lambRoot = fs.existsSync(runRoot) ? runRoot : devRoot; 

  if (data.dependencies) {
    data.dependencies.forEach(function(file) {
      gutil.log('adding dependency:', file);
      var functionDependency = path.join(data.folderPath, file);
      var globalDependency = path.join(lambRoot, file);
      
      // console.log('functionDependency', functionDependency);
      // console.log('globalDependency', globalDependency);
      
      //look in function directory for file
      if (fs.existsSync(functionDependency)) {
        fs.copySync(functionDependency, path.join(data.distPath, file));
        // fs.createReadStream(functionDependency).pipe(fs.createWriteStream(path.join(data.distPath, file)));
      }
      //look in global dependencies folder
      else if (fs.existsSync(globalDependency)) {
        fs.copySync(globalDependency, path.join(data.distPath, file));
        // fs.createReadStream(globalDependency).pipe(fs.createWriteStream(path.join(data.distPath, file)));
      }
    });
  }
  
  //copy function itself
  var functionFile = path.join(data.folderPath, data.functionName + '.js');
  gutil.log('copying function:', functionFile);
  fs.createReadStream(functionFile).pipe(fs.createWriteStream(path.join(data.distPath, data.functionName + '.js')));
  callback(null);
};<commit_msg>added logging for deploy<commit_after>var AWS           = require('aws-sdk')
    , fs          = require('fs-extra')
    , path        = require('path')
    , async       = require('async')
    , chalk       = require('chalk')
    , ncp         = require('ncp')
    , gulp        = require('gulp')
    , zip         = require('gulp-zip')
    , gutil       = require('gulp-util')
    , task        = require('gulp-task')
    , pkg         = require(process.cwd() + '/package.json')
    ;

var data = {
  folderPath: null,   //e.g. ./functions/hello-world
  distPath: null,     //e.g. ./dist/hello-world
  environment: null   //e.g. staging
};

  
var clean = function(callback) {
  gutil.log('cleanup prep...');

  fs.remove(path.join(process.cwd(), 'dist'), function(err) {
    if (err) return callback(err);
    fs.ensureDir(data.distPath, function(err) { callback(err); });
  });
};

var npm = function(callback) {
  gutil.log('copying NPM modules for deployment...');
  ncp(
    path.join(process.cwd(), 'node_modules'),
    path.join(data.distPath, 'node_modules'),
    function(err) { callback(err); }
  );

};

// var envFile = function(callback) {
//   console.log('copying .env file...');
//   //use environment specific .env file if there is one
//   fs.exists(path.join(data.folderPath, '.env.' + data.environment), function(exists) {
//     var filename = "";
    
//     if (exists) {
//       filename = path.join(data.folderPath, '.env.' + data.environment);
//       console.log(chalk.yellow('using .env.' + data.environment + '...'), filename);
//       fs.createReadStream(filename).pipe(fs.createWriteStream(path.join(data.distPath, '.env.' + data.environment)));
//     }
//     else {
//       filename = path.join(data.folderPath, '.env');
//       console.log('copying file:', filename);
//       fs.createReadStream(filename).pipe(fs.createWriteStream(path.join(data.distPath, '.env')));
//     }
    
//     callback(null);
//   });
// };

var makeDist = function(callback) {
  gutil.log('creating dist folder...');

  //copy any file dependencies
  var devRoot = path.join(process.cwd(), 'dependencies');
  var runRoot = path.join(process.cwd(), 'node_modules/lambinator/dependencies');
  var lambRoot = fs.existsSync(runRoot) ? runRoot : devRoot; 

  if (data.dependencies) {
    data.dependencies.forEach(function(file) {
      gutil.log('adding dependency:', file);
      var functionDependency = path.join(data.folderPath, file);
      var globalDependency = path.join(lambRoot, file);
      
      
      //look in function directory for file
      if (fs.existsSync(functionDependency)) {
        gutil.log('functionDependency', functionDependency);
        fs.copySync(functionDependency, path.join(data.distPath, file));
        // fs.createReadStream(functionDependency).pipe(fs.createWriteStream(path.join(data.distPath, file)));
      }
      //look in global dependencies folder
      else if (fs.existsSync(globalDependency)) {
        gutil.log('globalDependency', globalDependency);
        fs.copySync(globalDependency, path.join(data.distPath, file));
        // fs.createReadStream(globalDependency).pipe(fs.createWriteStream(path.join(data.distPath, file)));
      }
    });
  }
  
  //copy function itself
  var functionFile = path.join(data.folderPath, data.functionName + '.js');
  gutil.log('copying function:', functionFile);
  fs.createReadStream(functionFile).pipe(fs.createWriteStream(path.join(data.distPath, data.functionName + '.js')));
  callback(null);
};
{'fraction_non_alphanumeric': 0.17010970223678587, 'fraction_numerical': 0.0, 'mean_word_length': 2.9130434782608696, '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': '5354850', 'n_tokens_mistral': 2186, 'n_tokens_neox': 2155, 'n_words': 391}