Commit c2471a63 by Kevin Martensson

Don't write to stdout if `--output` is specified

Fixes #436.
parent fdd9868e
......@@ -162,7 +162,7 @@ module.exports = function(args) {
options.src = argv._[0];
options.dest = argv.o || argv._[1];
if (!options.dest) {
if (!options.dest && (process.stdout.isTTY || process.env.isTTY)) {
var suffix = '.css';
if (/\.css$/.test(options.src)) {
suffix = '';
......
......@@ -28,7 +28,7 @@ function render(options, emitter) {
}
};
if (options.stdout || (!process.stdout.isTTY && !process.env.isTTY)) {
if (options.stdout || (!options.dest && (!process.stdout.isTTY || !process.env.isTTY))) {
emitter.emit('log', css);
return done();
}
......
......@@ -47,6 +47,23 @@ describe('cli', function() {
src.pipe(emitter.stdin);
});
it('should write to disk when using --output', function(done) {
this.timeout(6000);
var src = fs.createReadStream(sampleScssPath);
var emitter = spawn(cliPath, ['--output', sampleCssOutputPath], {
stdio: [null, 'ignore', null]
});
emitter.on('close', function() {
fs.exists(sampleCssOutputPath, function(exists) {
assert(exists);
fs.unlink(sampleCssOutputPath, done);
});
});
src.pipe(emitter.stdin);
});
it('should print help when run with no arguments', function(done) {
var env = assign(process.env, { isTTY: true });
exec('node ' + cliPath, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment