Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make filenames optional

  • Loading branch information...
commit de48689023ce9095b53436b509c5b92cf27c3feb 1 parent 0af97e4
SLaks authored May 09, 2013

Showing 2 changed files with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 6  index.js
  2. 2  prelude.js
6  index.js
@@ -23,6 +23,7 @@ function newlinesIn(src) {
23 23
 
24 24
 module.exports = function (opts) {
25 25
     if (!opts) opts = {};
  26
+    if (opts.filenames === undefined) opts.filenames = true;
26 27
     var parser = opts.raw ? through() : JSONStream.parse([ true ]);
27 28
     var output = through(write, end);
28 29
     parser.pipe(output);
@@ -48,7 +49,8 @@ module.exports = function (opts) {
48 49
                 { line: lineno }
49 50
             );
50 51
         }
51  
-        allFilepaths.push(filenameMap[row.id] = (row.filename || row.sourceFile || row.id).replace(/\\/g, '/'));
  52
+        if (opts.filenames && (row.filename || row.sourceFile))
  53
+            allFilepaths.push(filenameMap[row.id] = (row.filename || row.sourceFile).replace(/\\/g, '/'));
52 54
         
53 55
         var wrappedSource = [
54 56
             (first ? '' : ','),
@@ -76,7 +78,7 @@ module.exports = function (opts) {
76 78
         entries = entries.filter(function (x) { return x !== undefined });
77 79
 
78 80
         this.queue('},{},' + JSON.stringify(entries));
79  
-        if (!allFilepaths.length) {
  81
+        if (!opts.filenames || !allFilepaths.length) {
80 82
             this.queue(',{}');
81 83
         } else {
82 84
             var basedir = opts.basedir
2  prelude.js
@@ -33,7 +33,7 @@
33 33
                     var id = modules[name][1][x];
34 34
                     return newRequire(id ? id : x, false, m);
35 35
                 },
36  
-                filename: filenames[name],  // filenames are passed in a separate map so that we can compute LCA after everything is finished
  36
+                filename: filenames[name] || name,  // filenames are passed in a separate map so that we can compute LCA after everything is finished
37 37
                 exports: {},
38 38
                 parent: parent || null,
39 39
                 children: [],

0 notes on commit de48689

Please sign in to comment.
Something went wrong with that request. Please try again.