pegjs/spec/server
David Majda 6fa8ad63f9 Replace some functions with arrow functions
Because arrow functions work rather differently than normal functions (a
bad design mistake if you ask me), I decided to be conservative with the
conversion.

I converted:

  * event handlers
  * callbacks
  * arguments to Array.prototype.map & co.
  * small standalone lambda functions

I didn't convert:

  * functions assigned to object literal properties (the new shorthand
    syntax would be better here)
  * functions passed to "describe", "it", etc. in specs (because Jasmine
    relies on dynamic "this")

See #442.
2016-09-12 16:07:43 +02:00

38 lines
869 B
JavaScript
Executable file

#!/usr/bin/env node
/* eslint-env node */
/* eslint no-console: 0 */
/*
* Small server whose main purpose is to ensure that both the specced code and
* the specs get passed through Babel & Browserify before they are served to the
* browser.
*/
let express = require("express"),
logger = require("morgan"),
glob = require("glob"),
browserify = require("browserify"),
babelify = require("babelify");
let app = express();
app.use(logger("dev"));
app.use(express.static(__dirname));
app.get("/bundle.js", (req, res) => {
let files = glob.sync(__dirname + "/**/*.js", {
ignore: __dirname + "/vendor/**/*"
});
browserify(files)
.transform(babelify, { presets: "es2015", compact: false })
.bundle()
.pipe(res);
});
app.listen(8000, () => {
console.log("Spec server running at http://localhost:8000...");
});