Skip to content

Commit

Permalink
Ignore unmatches globs or directories
Browse files Browse the repository at this point in the history
Closes GH-29.
  • Loading branch information
wooorm committed Nov 16, 2017
1 parent 4b65d2f commit c2b7aee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/file-set-pipeline/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function stdin(context, settings, next) {
var streamIn = settings.streamIn;
var err;

if (context.files.length !== 0) {
if (settings.files && settings.files.length !== 0) {
debug('Ignoring `streamIn`');

if (settings.filePath) {
Expand Down
6 changes: 5 additions & 1 deletion lib/file-set-pipeline/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function transform(context, settings, next) {

fileSet.on('add', add).on('done', next);

context.files.forEach(fileSet.add, fileSet);
if (context.files.length === 0) {
next();
} else {
context.files.forEach(fileSet.add, fileSet);
}

function add(file) {
filePipeline.run({
Expand Down
30 changes: 22 additions & 8 deletions test/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var join = path.join;
var fixtures = join(__dirname, 'fixtures');

test('input', function (t) {
t.plan(18);
t.plan(19);

t.test('should fail without input', function (st) {
var stream = new PassThrough();
Expand Down Expand Up @@ -50,6 +50,21 @@ test('input', function (t) {
stream.end('');
});

t.test('should not fail on unmatched given globs', function (st) {
var stderr = spy();

st.plan(1);

engine({
processor: unified,
cwd: join(fixtures, 'empty'),
streamError: stderr.stream,
files: ['.']
}, function (err, code) {
st.deepEqual([err, code, stderr()], [null, 0, '']);
});
});

t.test('should report unfound given files', function (st) {
var stderr = spy();

Expand Down Expand Up @@ -78,19 +93,18 @@ test('input', function (t) {
});
});

t.test('should report unfound given directories', function (st) {
t.test('should not report unfound given directories', function (st) {
var stderr = spy();

st.plan(1);

engine({
processor: unified,
cwd: join(fixtures, 'directory'),
streamError: stderr.stream,
files: ['empty/']
}, function (err) {
st.equal(
err.message,
'No input',
'should fail fatally when with an empty directory'
);
}, function (err, code) {
st.deepEqual([err, code, stderr()], [null, 0, '']);
});
});

Expand Down

0 comments on commit c2b7aee

Please sign in to comment.