Fix coding style in external/builder/builder.js

This commit is contained in:
Jonas Jenwald 2014-03-10 15:53:41 +01:00
parent ba8a59034c
commit 4f6b363b2c

View File

@ -1,3 +1,5 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* jshint node:true */ /* jshint node:true */
/* globals cp, ls, test */ /* globals cp, ls, test */
@ -32,10 +34,10 @@ function preprocess(inFilename, outFilename, defines) {
} }
return null; return null;
} }
var writeLine = typeof outFilename === 'function' ? outFilename : var writeLine = (typeof outFilename === 'function' ? outFilename :
function(line) { function(line) {
out += line + '\n'; out += line + '\n';
}; });
function include(file) { function include(file) {
var realPath = fs.realpathSync(inFilename); var realPath = fs.realpathSync(inFilename);
var dir = path.dirname(realPath); var dir = path.dirname(realPath);
@ -78,12 +80,14 @@ function preprocess(inFilename, outFilename, defines) {
state = stack.pop(); state = stack.pop();
break; break;
case 'expand': case 'expand':
if (state === 0 || state === 3) if (state === 0 || state === 3) {
expand(m[2]); expand(m[2]);
}
break; break;
case 'include': case 'include':
if (state === 0 || state === 3) if (state === 0 || state === 3) {
include(m[2]); include(m[2]);
}
break; break;
} }
} else { } else {
@ -94,10 +98,12 @@ function preprocess(inFilename, outFilename, defines) {
} }
} }
} }
if (state !== 0 || stack.length !== 0) if (state !== 0 || stack.length !== 0) {
throw new Error('Missing endif in preprocessor.'); throw new Error('Missing endif in preprocessor.');
if (typeof outFilename !== 'function') }
if (typeof outFilename !== 'function') {
fs.writeFileSync(outFilename, out); fs.writeFileSync(outFilename, out);
}
} }
exports.preprocess = preprocess; exports.preprocess = preprocess;
@ -198,8 +204,9 @@ function build(setup) {
sources.forEach(function(source) { sources.forEach(function(source) {
// ??? Warn if the source is wildcard and dest is file? // ??? Warn if the source is wildcard and dest is file?
var destWithFolder = destination; var destWithFolder = destination;
if (test('-d', destination)) if (test('-d', destination)) {
destWithFolder += '/' + path.basename(source); destWithFolder += '/' + path.basename(source);
}
preprocess(source, destWithFolder, defines); preprocess(source, destWithFolder, defines);
}); });
}); });
@ -219,10 +226,12 @@ exports.build = build;
*/ */
function merge(defaults, defines) { function merge(defaults, defines) {
var ret = {}; var ret = {};
for (var key in defaults) for (var key in defaults) {
ret[key] = defaults[key]; ret[key] = defaults[key];
for (key in defines) }
for (key in defines) {
ret[key] = defines[key]; ret[key] = defines[key];
}
return ret; return ret;
} }
exports.merge = merge; exports.merge = merge;