|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/* eslint-env node */
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
|
|
|
// 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 babelify = require("babelify");
|
|
|
|
let browserify = require("browserify");
|
|
|
|
let express = require("express");
|
|
|
|
let glob = require("glob");
|
|
|
|
let logger = require("morgan");
|
|
|
|
|
|
|
|
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...");
|
|
|
|
});
|