Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
cli: works with stdin & stdout
Browse files Browse the repository at this point in the history
Close #11
Close #12
  • Loading branch information
MoOx committed Aug 19, 2014
1 parent ec9741e commit 7acbbdf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bin/cssnext
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node

var colors = require("colors")
var fs = require("fs")
var path = require("path")

var colors = require("colors")
var program = require("commander")

var path = require("path")

var cssnext = require("..")
var pkg = require("../package")

Expand Down
17 changes: 16 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ test("sourcemap", function(t) {
test("cli", function(t) {
var exec = require("child_process").exec

var input = read("cli/input")
var output = read("cli/input.expected")

var planned = 0
Expand All @@ -99,6 +100,20 @@ test("cli", function(t) {
})
planned+=1

exec("bin/cssnext test/cli/input.css", function(err, stdout) {
if (err) { throw err }
t.equal(stdout, output, "should read from a file and write to stdout")
})
planned+=1

var childProcess = exec("bin/cssnext", function(err, stdout) {
if (err) { throw err }
t.equal(stdout, output, "should read from stdin and write to stdout")
})
childProcess.stdin.write(new Buffer(input))
childProcess.stdin.end()
planned+=1

exec("bin/cssnext test/cli/wtf.css", function(err, stdout, stderr) {
t.ok(err && err.code === 1, "should return an error when input file is unreadable")
t.ok(contains(stderr, "Unable to read file"), "should show that the input file is not found")
Expand All @@ -115,7 +130,7 @@ test("cli", function(t) {
t.plan(planned)
})

/*
/**
* Resolve a fixture by `filename`.
*
* @param {String} filename
Expand Down

0 comments on commit 7acbbdf

Please sign in to comment.