<commit_before>'use strict'

const path = require('path')
const os = require('os')
const aws = require('aws-sdk')
const exec = require('child_process').exec
const execSync = require('child_process').execSync
const execFile = require('child_process').execFile
const fs = require('fs-extra')
const klaw = require('klaw')
const packageJson = require(path.join(__dirname, '..', 'package.json'))
const minimatch = require('minimatch')
const archiver = require('archiver')
const dotenv = require('dotenv')
const proxy = require('proxy-agent')
const ScheduleEvents = require(path.join(__dirname, 'schedule_events'))
const S3Events = require(path.join(__dirname, 's3_events'))
const CloudWatchLogs = require(path.join(__dirname, 'cloudwatch_logs'))

const AWSXRay = require('aws-xray-sdk-core')
const createNamespace = require('continuation-local-storage').createNamespace

const maxBufferSize = 50 * 1024 * 1024

class Lambda {
  constructor () {
    this.version = packageJson.version
  }

  _createSampleFile (file, boilerplateName) {
    const exampleFile = path.join(process.cwd(), file)
    const boilerplateFile = path.join(
      __dirname,
      (boilerplateName || file) + '.example'
    )

    if (!fs.existsSync(exampleFile)) {
      fs.writeFileSync(exampleFile, fs.readFileSync(boilerplateFile))
      console.log(exampleFile + ' file successfully created')
    }
  }

  setup (program) {
    console.log('Running setup.')
    this._createSampleFile('.env', '.env')
    this._createSampleFile(program.eventFile, 'event.json')
    this._createSampleFile('deploy.env', 'deploy.env')
    this._createSampleFile(program.contextFile, 'context.json')
    this._createSampleFile('event_sources.json', 'event_sources.json')
    console.log(`Setup done.
Edit the .env, deploy.env, ${program.contextFile}, \
event_sources.json and ${program.eventFile} files as needed.`)
  }

  run (program) {
    if (['nodejs4.3', 'nodejs6.10', 'nodejs8.10'].indexOf(program.runtime) === -1) {
      console.error(`Runtime [${program.runtime}] is not supported.`)
      process.exit(254)
    }

    this._createSampleFile(program.eventFile, 'event.json')
    const splitHandler = program.handler.split('.')
    const filename = splitHandler[0] + '.js'
    const handlername = splitHandler[1]

    // Set custom environment variables if program.configFile is defined
    if (program.configFile) {
      this._setRunTimeEnvironmentVars(program)<commit_msg>Fix to use `includes` instead of `indexOf` (#433)<commit_after>'use strict'

const path = require('path')
const os = require('os')
const aws = require('aws-sdk')
const exec = require('child_process').exec
const execSync = require('child_process').execSync
const execFile = require('child_process').execFile
const fs = require('fs-extra')
const klaw = require('klaw')
const packageJson = require(path.join(__dirname, '..', 'package.json'))
const minimatch = require('minimatch')
const archiver = require('archiver')
const dotenv = require('dotenv')
const proxy = require('proxy-agent')
const ScheduleEvents = require(path.join(__dirname, 'schedule_events'))
const S3Events = require(path.join(__dirname, 's3_events'))
const CloudWatchLogs = require(path.join(__dirname, 'cloudwatch_logs'))

const AWSXRay = require('aws-xray-sdk-core')
const createNamespace = require('continuation-local-storage').createNamespace

const maxBufferSize = 50 * 1024 * 1024

class Lambda {
  constructor () {
    this.version = packageJson.version
  }

  _createSampleFile (file, boilerplateName) {
    const exampleFile = path.join(process.cwd(), file)
    const boilerplateFile = path.join(
      __dirname,
      (boilerplateName || file) + '.example'
    )

    if (!fs.existsSync(exampleFile)) {
      fs.writeFileSync(exampleFile, fs.readFileSync(boilerplateFile))
      console.log(exampleFile + ' file successfully created')
    }
  }

  setup (program) {
    console.log('Running setup.')
    this._createSampleFile('.env', '.env')
    this._createSampleFile(program.eventFile, 'event.json')
    this._createSampleFile('deploy.env', 'deploy.env')
    this._createSampleFile(program.contextFile, 'context.json')
    this._createSampleFile('event_sources.json', 'event_sources.json')
    console.log(`Setup done.
Edit the .env, deploy.env, ${program.contextFile}, \
event_sources.json and ${program.eventFile} files as needed.`)
  }

  run (program) {
    if (!['nodejs4.3', 'nodejs6.10', 'nodejs8.10'].includes(program.runtime)) {
      console.error(`Runtime [${program.runtime}] is not supported.`)
      process.exit(254)
    }

    this._createSampleFile(program.eventFile, 'event.json')
    const splitHandler = program.handler.split('.')
    const filename = splitHandler[0] + '.js'
    const handlername = splitHandler[1]

    // Set custom environment variables if program.configFile is defined
    if (program.configFile) {
      this._setRunTimeEnvironmentVars(program)
{'fraction_non_alphanumeric': 0.14119567435217303, 'fraction_numerical': 0.011018159559273618, 'mean_word_length': 4.640966628308401, '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': '7604575', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1454, 'n_words': 315}