<commit_before>'use strict'

const path = require('path')
const webpack = require('webpack')

class ServerlessPluginWebpack {
  constructor (serverless, options) {
    this.serverless = serverless
    this.options = options
    this.hooks = {
      'before:deploy:initialize': this.bundle.bind(this)
    }
  }

  bundle () {
    this.serverless.cli.log('Bundling service...')
    return new Promise((resolve, reject) => {
      const config = require(path.join(this.serverless.config.servicePath, 'webpack.config.js'))
      webpack(config, (error, stats) => {
        if (error) {
          reject(error)
        }

        let jsonStats = stats.toJson()
        let stringStats = stats.toString({
          chunks: false,
          colors: true
        })
        console.log('[webpack:build]', stringStats)

        if (jsonStats.errors.length > 0) {
          reject('webpack build failed')
        }

        if(jsonStats.warnings.length > 0) {
          reject('webpack build failed')
        }

        resolve()
      })<commit_msg>use webpack_stage option as environment variable<commit_after>'use strict'

const path = require('path')
const webpack = require('webpack')

class ServerlessPluginWebpack {
  constructor (serverless, options) {
    this.serverless = serverless
    this.options = options
    process.env.webpack_stage = options.webpack_stage || 'dev'

    this.hooks = {
      'before:deploy:initialize': this.bundle.bind(this)
    }
  }

  bundle () {
    this.serverless.cli.log('Bundling service...')
    return new Promise((resolve, reject) => {
      const config = require(path.join(this.serverless.config.servicePath, 'webpack.config.js'))
      webpack(config, (error, stats) => {
        if (error) {
          reject(error)
        }

        let jsonStats = stats.toJson()
        let stringStats = stats.toString({
          chunks: false,
          colors: true
        })
        console.log('[webpack:build]', stringStats)

        if (jsonStats.errors.length > 0) {
          reject('webpack build failed')
        }

        if(jsonStats.warnings.length > 0) {
          reject('webpack build failed')
        }

        resolve()
      })
{'fraction_non_alphanumeric': 0.12666360715924735, 'fraction_numerical': 0.0018357044515832951, 'mean_word_length': 2.390357698289269, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4162352', 'n_tokens_mistral': 634, 'n_tokens_neox': 618, 'n_words': 130}