#!/usr/bin/env node

// Native
const path = require('path')

// Packages
const asyncToGen = require('async-to-gen/register')
const updateNotifier = require('update-notifier')
const {red} = require('chalk')
const nodeVersion = require('node-version')
const isAsyncSupported = require('is-async-supported')

// Ours
const pkg = require('../package')

// Support for keywords "async" and "await"
if (!isAsyncSupported()) {
  const pathSep = process.platform === 'win32' ? '\\\\' : '/'
  const directoryName = path.parse(path.join(__dirname, '..')).base

  asyncToGen({
    includes: new RegExp(`.*${directoryName}?${pathSep}(lib|bin).*`),
    excludes: null,
    sourceMaps: false
  })
}

// Throw an error if node version is too low
if (nodeVersion.major < 6) {
  console.error(`${red('Error!')} Serve requires at least version 6 of Node. Please upgrade!`)
  process.exit(1)
}

// Let user know if there's an update
// This isn't important when deployed to Now
if (!process.env.NOW && pkg.dist) {
  updateNotifier({pkg}).notify()
}

// Load package core with async/await support
require('../lib')

@@ -425,97 +425,21 @@
 nst 
-pathSep = process.platform === 'win32' ? '%5C%5C%5C%5C' : '/'%0A  const directoryName = path.parse(
+modulesDir = 
 path
@@ -463,15 +463,25 @@
 '..'
-)).base
+, 'node_modules')
 %0A%0A  
@@ -497,18 +497,18 @@
 n(%7B%0A    
-in
+ex
 cludes: 
@@ -527,66 +527,23 @@
 .*$%7B
-directoryName%7D?$%7BpathSep%7D(lib%7Cbin).*%60),%0A    excludes: null
+modulesDir%7D.*%60)
 ,%0A  

Exclude `node_modules` from transpilation explicitly