Skip to content

Commit

Permalink
fix problem where you couldnt catch singular glob errors. add sourcem…
Browse files Browse the repository at this point in the history
…aps into src
  • Loading branch information
Contra committed May 12, 2015
1 parent 12dec99 commit 60685eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ fs.src(['*.js', '!b*.js'])
```

- Possible options for the second argument:
- cwd - Specify the working directory the folder is relative to. Default is `process.cwd()`
- cwd - Specify the working directory the folder is relative to.
- Default is `process.cwd()`
- base - Specify the folder relative to the cwd. Default is where the glob begins. This is used to determine the file names when saving in `.dest()`
- buffer - `true` or `false` if you want to buffer the file.
- Default value is `true`
Expand All @@ -60,6 +61,9 @@ fs.src(['*.js', '!b*.js'])
- `false` will disable writing the file to disk via `.dest()`
- since - `Date` or `number` if you only want files that have been modified since the time specified.
- passthrough - `true` or `false` if you want a duplex stream which passes items through and emits globbed files.
- Default is `false`.
- sourcemaps - `true` or `false` if you want files to have sourcemaps enabled.
- Default is `false`.
- Any glob-related options are documented in [glob-stream] and [node-glob]
- Returns a Readable stream by default, or a Duplex stream if the `passthrough` option is set to `true`.
- This stream emits matching [vinyl] File objects
Expand Down
17 changes: 12 additions & 5 deletions lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ var gs = require('glob-stream');
var File = require('vinyl');
var duplexify = require('duplexify');
var merge = require('merge-stream');

var sourcemaps = require('gulp-sourcemaps');
var filterSince = require('vinyl-filter-since');

var getContents = require('./getContents');
var resolveSymlinks = require('./resolveSymlinks');

Expand All @@ -18,7 +19,9 @@ function createFile(globFile, enc, cb) {
function src(glob, opt) {
var options = assign({
read: true,
buffer: true
buffer: true,
sourcemaps: false,
passthrough: false
}, opt);
var pass, inputPass;

Expand All @@ -40,7 +43,7 @@ function src(glob, opt) {
.pipe(resolveSymlinks())
.pipe(through.obj(createFile));

if (options.since) {
if (options.since != null) {
outputStream = outputStream
.pipe(filterSince(options.since));
}
Expand All @@ -50,11 +53,15 @@ function src(glob, opt) {
.pipe(getContents(options));
}

if (options.passthrough) {
if (options.passthrough === true) {
inputPass = through.obj();
outputStream = duplexify.obj(inputPass, merge(outputStream, inputPass));
}

if (options.sourcemaps === true) {
outputStream = outputStream
.pipe(sourcemaps.init({loadMaps: true}));
}
globStream.on('error', outputStream.emit.bind(outputStream, 'error'));
return outputStream;
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"glob-stream": "^5.0.0",
"glob-watcher": "^2.0.0",
"graceful-fs": "^3.0.0",
"gulp-sourcemaps": "^1.5.2",
"merge-stream": "^0.1.7",
"mkdirp": "^0.5.0",
"object-assign": "^2.0.0",
Expand Down

2 comments on commit 60685eb

@onlywei
Copy link

@onlywei onlywei commented on 60685eb Jun 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for the great work!! I love this feature!

Just curious if you have any timeline for a release tag including this feature?

@yocontra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onlywei You can use github for this temporarily, there are some other changes still in-progress for the next breaking release

Please sign in to comment.