Commit cc147f63 authored by Evan Hahn's avatar Evan Hahn

Add /dev route to dev server for debugging

parent 089f03a4
const express = require('express')
const path = require('path')
const readSource = require('./read-source')
const minify = require('./minify')
const app = express()
......@@ -13,6 +14,13 @@ app.get('/', async (req, res) => {
res.render('shim', { output, byteCount })
})
app.get('/dev', async (req, res) => {
const outputBuffer = await readSource()
const byteCount = outputBuffer.length
const output = outputBuffer.toString('utf8')
res.render('shim', { output, byteCount })
})
const port = process.env.PORT || 3000
app.listen(port, () => {
console.log('App started on :' + port)
......
const path = require('path')
const fs = require('fs')
const util = require('util')
const childProcess = require('child_process')
const RegPack = require('regpack').RegPack
const readSource = require('./read-source')
const readFile = util.promisify(fs.readFile)
const execFile = util.promisify(childProcess.execFile)
const SOURCE_PATH = path.join(__dirname, 'js1k.js')
......@@ -13,7 +12,7 @@ const BABEL_MINIFY_PATH = path.join(BIN_PATH, 'minify')
const BABEL_MINIFY_OPTIONS = ['--builtIns', '--booleans', '--mangle', '--infinity', '--flipComparisons', '--mangle.topLevel']
module.exports = async function minify () {
const rawSource = await readFile(SOURCE_PATH)
const rawSource = await readSource()
const babelResult = await babelMinify()
const regPackResult = regpackMinify(babelResult)
......
const path = require('path')
const fs = require('fs')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const SOURCE_PATH = path.join(__dirname, 'js1k.js')
module.exports = async function readSource () {
return readFile(SOURCE_PATH)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment