<commit_before>// https://github.com/petehunt/webpack-howto/blob/master/README.md#8-optimizing-common-code
// https://www.jonathan-petitcolas.com/2016/08/12/plugging-webpack-to-jekyll-powered-pages.html
// https://webpack.github.io/docs/configuration.html#resolve-alias
// https://github.com/HenrikJoreteg/hjs-webpack
// http://webpack.github.io/docs/webpack-dev-middleware.html
// http://stackoverflow.com/a/28989476/151666
// https://github.com/webpack/webpack-dev-server/issues/97#issuecomment-70388180
// https://webpack.github.io/docs/hot-module-replacement.html
// https://github.com/css-modules/webpack-demo/issues/8#issuecomment-133922019
// https://github.com/gowravshekar/font-awesome-webpack
// https://webpack.github.io/docs/code-splitting.html#split-app-and-vendor-code
var _ = require('lodash')
var path = require('path')
var utils = require('./utils')
var fs = require('fs')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var webpack = require('webpack')
var webpackDevMiddleware = require('webpack-dev-middleware')
var webpackHotMiddleware = require('webpack-hot-middleware')
var BowerWebpackPlugin = require('bower-webpack-plugin')

var runtime = {}

runtime.lanyonDir = __dirname
runtime.lanyonEnv = process.env.LANYON_ENV || 'development'
runtime.lanyonPackageFile = path.join(runtime.lanyonDir, 'package.json')
var lanyonPackage = require(runtime.lanyonPackageFile)
runtime.lanyonVersion = lanyonPackage.version

runtime.trace = process.env.LANYON_TRACE === '1'
runtime.publicPath = '/assets/build/'

runtime.rubyProvidersOnly = (process.env.LANYON_ONLY || '')
runtime.rubyProvidersSkip = (process.env.LANYON_SKIP || '').split(/\s+/)

runtime.lanyonReset = process.env.LANYON_RESET === '1'
runtime.onTravis = process.env.TRAVIS === 'true'
runtime.ghPagesEnv = {
  GHPAGES_URL: process.env.GHPAGES_URL,
  GHPAGES_BOTNAME: process.env.GHPAGES_BOTNAME,
  GHPAGES_BOTEMAIL: process.env.GHPAGES_BOTEMAIL
}
runtime.isDev = runtime.lanyonEnv === 'development'
runtime.isHotLoading = runtime.isDev && ['serve', 'start'].indexOf(process.argv[2]) !== -1

runtime.projectDir = process.env.LANYON_PROJECT || process.env.PWD || process.cwd() // <-- symlinked npm will mess up process.cwd() and point to ~/code/lanyon

runtime.npmRoot = utils.upwardDirContaining('package.json', runtime.projectDir, 'lanyon')
if (!runtime.npmRoot) {
  throw new Error('Unable to determine non-lanyon npmRoot')
}
runtime.gitRoot = utils.upwardDirContaining('.git', runtime.npmRoot)

runtime.projectPackageFile = path.join(runtime.npmRoot, 'package.json')
try {
  var projectPackage = require(runtime.projectPackageFile)
} catch (e) {
  projectPackage = {}
}

runtime.gems = _.defaults(_.get(projectPackage, 'lanyon.gems') || {}, _.get(lanyonPackage, 'lanyon.gems'))
runtime = _.defaults(projectPackage.lanyon || {}, lanyonPackage.lanyon, runtime)

try {
  runtime.projectDir = fs.realpathSync(runtime.projectDir)
} catch (e) {
  runtime.projectDir = fs.realpathSync(runtime.gitRoot + '/' + runtime.projectDir)
}

runtime.cacheDir = path.join(runtime.projectDir, '.lanyon')
runtime.binDir = path.join(runtime.cacheDir, 'bin')
runtime.recordsPath = path.join(runtime.cacheDir, 'records.json')
runtime.assetsSourceDir = path.join(runtime.projectDir, 'assets')
runtime.assetsBuildDir = path.join(runtime.assetsSourceDir, 'build')
runtime.contentBuildDir = path.join(runtime.projectDir, '_site')

// Set prerequisite defaults
for (var name in runtime.prerequisites) {
  if (!runtime.prerequisites[name].exeSuffix) {
    runtime.prerequisites[name].exeSuffix = ''
  }<commit_msg>Avoid fatal: throw new Error('Unable to determine non-lanyon npmRoot')<commit_after>// https://github.com/petehunt/webpack-howto/blob/master/README.md#8-optimizing-common-code
// https://www.jonathan-petitcolas.com/2016/08/12/plugging-webpack-to-jekyll-powered-pages.html
// https://webpack.github.io/docs/configuration.html#resolve-alias
// https://github.com/HenrikJoreteg/hjs-webpack
// http://webpack.github.io/docs/webpack-dev-middleware.html
// http://stackoverflow.com/a/28989476/151666
// https://github.com/webpack/webpack-dev-server/issues/97#issuecomment-70388180
// https://webpack.github.io/docs/hot-module-replacement.html
// https://github.com/css-modules/webpack-demo/issues/8#issuecomment-133922019
// https://github.com/gowravshekar/font-awesome-webpack
// https://webpack.github.io/docs/code-splitting.html#split-app-and-vendor-code
var _ = require('lodash')
var path = require('path')
var utils = require('./utils')
var fs = require('fs')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var webpack = require('webpack')
var webpackDevMiddleware = require('webpack-dev-middleware')
var webpackHotMiddleware = require('webpack-hot-middleware')
var BowerWebpackPlugin = require('bower-webpack-plugin')

var runtime = {}

runtime.lanyonDir = __dirname
runtime.lanyonEnv = process.env.LANYON_ENV || 'development'
runtime.lanyonPackageFile = path.join(runtime.lanyonDir, 'package.json')
var lanyonPackage = require(runtime.lanyonPackageFile)
runtime.lanyonVersion = lanyonPackage.version

runtime.trace = process.env.LANYON_TRACE === '1'
runtime.publicPath = '/assets/build/'

runtime.rubyProvidersOnly = (process.env.LANYON_ONLY || '')
runtime.rubyProvidersSkip = (process.env.LANYON_SKIP || '').split(/\s+/)

runtime.lanyonReset = process.env.LANYON_RESET === '1'
runtime.onTravis = process.env.TRAVIS === 'true'
runtime.ghPagesEnv = {
  GHPAGES_URL: process.env.GHPAGES_URL,
  GHPAGES_BOTNAME: process.env.GHPAGES_BOTNAME,
  GHPAGES_BOTEMAIL: process.env.GHPAGES_BOTEMAIL
}
runtime.isDev = runtime.lanyonEnv === 'development'
runtime.isHotLoading = runtime.isDev && ['serve', 'start'].indexOf(process.argv[2]) !== -1

runtime.projectDir = process.env.LANYON_PROJECT || process.env.PWD || process.cwd() // <-- symlinked npm will mess up process.cwd() and point to ~/code/lanyon

runtime.npmRoot = utils.upwardDirContaining('package.json', runtime.projectDir, 'lanyon')
if (!runtime.npmRoot) {
  console.error('--> Unable to determine non-lanyon npmRoot, falling back to ' + runtime.projectDir)
  runtime.npmRoot = runtime.projectDir
}
runtime.gitRoot = utils.upwardDirContaining('.git', runtime.npmRoot)

runtime.projectPackageFile = path.join(runtime.npmRoot, 'package.json')
try {
  var projectPackage = require(runtime.projectPackageFile)
} catch (e) {
  projectPackage = {}
}

runtime.gems = _.defaults(_.get(projectPackage, 'lanyon.gems') || {}, _.get(lanyonPackage, 'lanyon.gems'))
runtime = _.defaults(projectPackage.lanyon || {}, lanyonPackage.lanyon, runtime)

try {
  runtime.projectDir = fs.realpathSync(runtime.projectDir)
} catch (e) {
  runtime.projectDir = fs.realpathSync(runtime.gitRoot + '/' + runtime.projectDir)
}

runtime.cacheDir = path.join(runtime.projectDir, '.lanyon')
runtime.binDir = path.join(runtime.cacheDir, 'bin')
runtime.recordsPath = path.join(runtime.cacheDir, 'records.json')
runtime.assetsSourceDir = path.join(runtime.projectDir, 'assets')
runtime.assetsBuildDir = path.join(runtime.assetsSourceDir, 'build')
runtime.contentBuildDir = path.join(runtime.projectDir, '_site')

// Set prerequisite defaults
for (var name in runtime.prerequisites) {
  if (!runtime.prerequisites[name].exeSuffix) {
    runtime.prerequisites[name].exeSuffix = ''
  }
{'fraction_non_alphanumeric': 0.1549855986833082, 'fraction_numerical': 0.012892607324098204, 'mean_word_length': 5.419014084507042, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 18, 'lorem ipsum': 0, 'www.': 2, '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': '2031234', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2392, 'n_words': 353}