Skip to content

Commit

Permalink
Misc fixes and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pitaj committed Mar 14, 2017
1 parent 80e41f1 commit 450a153
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Expand Up @@ -4,6 +4,7 @@

const fs = require('fs');
const async = require('async');
const mkdirp = require('mkdirp');
const babel = require('babel-core');

const bench = require('./tests/bench');
Expand Down Expand Up @@ -101,6 +102,7 @@ module.exports = function Gruntfile(grunt) {

next(null, transpiled);
},
(file, next) => mkdirp('build', err => next(err, file)),
(file, next) => fs.writeFile('build/benchpress.js', file, next),
], done);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/benchpress.js
Expand Up @@ -21,7 +21,7 @@ const runtime = require('./compiler/runtime');
* @param {object} options
* @param {string} options.source - Template source
* @param {string} [options.name] - Name of template
* @param {boolean} [options.minify] - Whether to output a minified file
* @param {boolean} [options.minify] - Whether to output minified code
* @param {function} callback - (err, output)
*/
Benchpress.precompile = function precompile({ source, name, minify }, callback) {
Expand Down Expand Up @@ -111,7 +111,7 @@ Benchpress.evaluate = function evaluate(code) {
},
};
vm.runInNewContext(code, context, {
timeout: 10,
timeout: 20,
});
const template = context.module.exports;

Expand Down
9 changes: 4 additions & 5 deletions lib/compiler/codegen.js
@@ -1,11 +1,10 @@
'use strict';

const babel = require('babel-core');
const generate = require('babel-generator').default;

const defaults = {
// minified: global.env === 'development',
minified: true,
presets: ['babili'],
minified: false,
quotes: 'single',
};

/**
Expand All @@ -14,7 +13,7 @@ const defaults = {
* @param {object} options - Babel generator options
*/
function codegen(compiled, options) {
const { code } = babel.transformFromAst(compiled, Object.assign({}, defaults, options));
const { code } = generate(compiled, Object.assign({}, defaults, options));

return code;
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -16,6 +16,8 @@
"javascript"
],
"devDependencies": {
"async": "^2.1.5",
"babel-core": "^6.23.1",
"babel-plugin-check-es2015-constants": "^6.22.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0",
Expand All @@ -31,6 +33,7 @@
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-mocha-test": "^0.12.7",
"mkdirp": "^0.5.1",
"mocha": "^2.2.5",
"request": "^2.65.0",
"winston": "^0.7.3"
Expand All @@ -40,8 +43,7 @@
"node": ">=6"
},
"dependencies": {
"async": "^2.1.5",
"babel-core": "^6.23.1",
"babel-generator": "^6.24.0",
"babel-types": "^6.23.0",
"uglify-js": "^2.6.4"
}
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/utils.js
Expand Up @@ -3,6 +3,7 @@
const fs = require('fs');
const path = require('path');
const async = require('async');
const mkdirp = require('mkdirp');

const benchpress = require('../../lib/benchpress');

Expand Down Expand Up @@ -45,6 +46,7 @@ function compileTemplate(src, dest, callback) {
async.waterfall([
next => fs.readFile(src, next),
(file, next) => benchpress.precompile({ source: file.toString() }, next),
(code, next) => mkdirp(path.dirname(dest), err => next(err, code)),
(code, next) => fs.writeFile(dest, code, next),
], callback);
}
Expand Down

0 comments on commit 450a153

Please sign in to comment.