Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Writes css output to stdout if you pass the parameter --out stdout. #764

Closed
wants to merge 1 commit into from

4 participants

Timothy Strimple Jason Lewis Roman Komarov TJ Holowaychuk
Timothy Strimple

This change allows you to pass in a file, but instead of writing the .css to disk, it sends it to stdout. The usage is: stylus --out stdout file.styl. This is to get around the fact that paths are not available when using --line-numbers and sending in content via stdin.

An alternative to this approach would be to add an option to override the path which is displayed in debug which may be a better approach since you could then use relative paths for the debug information.

Timothy Strimple Add support for --out stdout
Writes css output to stdout if you pass the parameter --out stdout.
a097cf8
TJ Holowaychuk tj commented on the diff
bin/stylus
@@ -525,6 +525,12 @@ function compileFile(file) {
*/
function writeFile(file, css) {
+ if(dest === 'stdout') {
+ // Write to stdout instead of file
+ console.log(css);
+ return;
+ }
TJ Holowaychuk
tj added a note

looks fine but let's use process.stdout.write(css) instead because console.log will attempt to translate % etc so for general purpose stdout
it's not so great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
TJ Holowaychuk tj commented on the diff
bin/stylus
@@ -525,6 +525,12 @@ function compileFile(file) {
*/
function writeFile(file, css) {
+ if(dest === 'stdout') {
TJ Holowaychuk
tj added a note

if (dest == 'stdout') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Timothy Strimple

Good to note on stdout, I was just following the convention used in the rest of the file.

default:
  var stdin = process.openStdin();
  stdin.setEncoding('utf8');
  stdin.on('data', function(chunk){ str += chunk; });
  stdin.on('end', function(){
    var out = stylus.convertCSS(str);
    console.log(out);
  });

And

style.render(function(err, css){
  if (err) throw err;
  if (compare) {
    console.log('\n\x1b[1mInput:\x1b[0m');
    console.log(str);
    console.log('\n\x1b[1mOutput:\x1b[0m');
  }
  console.log(css);
  if (compare) console.log();
});

Should those be cleaned up as well?

Jason Lewis

Any word on this? Is there no way to have the compiled contents outputting in the terminal much like how Sass and Less do?

Perhaps another option like --print would be better, this is what CoffeeScript has.

Roman Komarov
Owner

Cloising this in favor of #1108

Roman Komarov kizu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 26, 2012
  1. Add support for --out stdout

    Timothy Strimple authored
    Writes css output to stdout if you pass the parameter --out stdout.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 bin/stylus
6 bin/stylus
View
@@ -525,6 +525,12 @@ function compileFile(file) {
*/
function writeFile(file, css) {
+ if(dest === 'stdout') {
TJ Holowaychuk
tj added a note

if (dest == 'stdout') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ // Write to stdout instead of file
+ console.log(css);
+ return;
+ }
TJ Holowaychuk
tj added a note

looks fine but let's use process.stdout.write(css) instead because console.log will attempt to translate % etc so for general purpose stdout
it's not so great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
// --out support
var path = dest
? join(dest, basename(file, '.styl') + '.css')
Something went wrong with that request. Please try again.