Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update compile.js #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions support/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Module dependencies.
*/

var fs = require('fs');
let fs = require('fs');

/**
* Arguments.
*/

var args = process.argv.slice(2)
let args = process.argv.slice(2)
, pending = args.length
, files = {};

Expand All @@ -18,7 +18,7 @@ console.log('');
// parse arguments

args.forEach(function(file){
var mod = file.replace('lib/', '');
let mod = file.replace('lib/', '');
fs.readFile(file, 'utf8', function(err, js){
if (err) throw err;
console.log(' \033[90mcompile : \033[0m\033[36m%s\033[0m', file);
Expand Down Expand Up @@ -56,15 +56,15 @@ function parseInheritance(js) {
*/

function parseConditionals(js) {
var lines = js.split('\n')
let lines = js.split('\n')
, len = lines.length
, buffer = true
, browser = false
, buf = []
, line
, cond;

for (var i = 0; i < len; ++i) {
for (let i = 0; i < len; ++i) {
line = lines[i];
if (/^ *\/\/ *if *(node|browser)/gm.exec(line)) {
cond = RegExp.$1;
Expand All @@ -87,7 +87,7 @@ function parseConditionals(js) {
*/

function compile() {
var buf = '';
let buf = '';
buf += 'ejs = (function(){\n';
buf += '\n// CommonJS require()\n\n';
buf += browser.require + '\n\n';
Expand All @@ -96,7 +96,7 @@ function compile() {
buf += 'require.register = ' + browser.register + ';\n\n';
buf += 'require.relative = ' + browser.relative + ';\n\n';
args.forEach(function(file){
var js = files[file];
let js = files[file];
file = file.replace('lib/', '');
buf += '\nrequire.register("' + file + '", function(module, exports, require){\n';
buf += js;
Expand All @@ -113,7 +113,7 @@ function compile() {
// refactored version of weepy's
// https://github.com/weepy/brequire/blob/master/browser/brequire.js

var browser = {
let browser = {

/**
* Require a module.
Expand Down Expand Up @@ -174,4 +174,4 @@ var browser = {
register: function(path, fn){
require.modules[path] = fn;
}
};
};