-
Notifications
You must be signed in to change notification settings - Fork 510
CLI: Only read stdin if there were no files supplied and not in tty mode. #567
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,7 +208,7 @@ describe('modules/cli', function() { | |
}); | ||
}); | ||
|
||
it('should should accept empty input being piped', function(done) { | ||
it('should accept empty input being piped', function(done) { | ||
// 'cat myEmptyFile.js | jscs' should report a successful run | ||
rAfter(); | ||
|
||
|
@@ -233,6 +233,34 @@ describe('modules/cli', function() { | |
done(); | ||
}); | ||
}); | ||
|
||
it('should not accept piped input if files were specified (#563)', function() { | ||
var checker = require('../lib/checker'); | ||
var spy = sinon.spy(checker.prototype, 'checkPath'); | ||
|
||
var result = cli({ | ||
args: [__dirname + '/data/cli/success.js'] | ||
}); | ||
|
||
return result.promise.always(function() { | ||
assert(spy.called); | ||
checker.prototype.checkPath.restore(); | ||
rAfter(); | ||
}); | ||
}); | ||
|
||
it('should check stdin if - was supplied as the last argument (#563)', function() { | ||
var spy = sinon.spy(process.stdin, 'on'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @markelog Restoring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, it's already restored, by the time the test is done, so we don't need to do that ourselves |
||
|
||
var result = cli({ | ||
args: [__dirname + '/data/cli/success.js', '-'] | ||
}); | ||
|
||
return result.promise.always(function() { | ||
assert(spy.called); | ||
rAfter(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('reporter option', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as in test below you need to
restore
the method you are spying on – see "Spying on existing methods" in hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restoring this method works well. Good catch. Done.