Permalink
Browse files

Merge pull request #26 from fnogatz/master

Added support for JSON files
  • Loading branch information...
2 parents 9ae2590 + c9aa8d7 commit 4f2cda165bedfbfb1535d19811833a1acb45efab @rauchg rauchg committed Feb 2, 2013
Showing with 23 additions and 17 deletions.
  1. +23 −17 lib/browserbuild.js
View
@@ -70,26 +70,32 @@ Renderer.prototype._render = function(filepath) {
}
})
- // remove `if node`
- var ignoring = false
-
- source = source.split('\n').map(function (line, i) {
- if (ignoring) {
- if (/^ *\/\/ *end/.test(line)) {
- ignoring = false;
- }
- return '';
- } else {
- if (/^ *\/\/ *if *node/.test(line)) {
- debug('[%s] skipping node-only code at line %d'
- , path.basename(filepath), i + 1);
- ignoring = true;
+ if (/\.json$/.test(filepath)) {
+ // JSON file
+ source = 'module.exports = '+source;
+ }
+ else {
+ // remove `if node`
+ var ignoring = false
+
+ source = source.split('\n').map(function (line, i) {
+ if (ignoring) {
+ if (/^ *\/\/ *end/.test(line)) {
+ ignoring = false;
+ }
return '';
} else {
- return line;
+ if (/^ *\/\/ *if *node/.test(line)) {
+ debug('[%s] skipping node-only code at line %d'
+ , path.basename(filepath), i + 1);
+ ignoring = true;
+ return '';
+ } else {
+ return line;
+ }
}
- }
- }).join('\n');
+ }).join('\n');
+ }
// wrap
return 'require.register("' + filepath + '", '

0 comments on commit 4f2cda1

Please sign in to comment.