gobblejs / gobble

The last build tool you'll ever need
333 stars 20 forks source link

Is there a way to skip creation of a file with a file transformer? #103

Closed fskreuz closed 8 years ago

fskreuz commented 8 years ago

Was thinking of something like

function transform(contents, options){
  // parsing
  return contents.something ? parsedContents : null;
}

Where null would tell gobble to not create the resulting file. It's possible with directory transformers but it's a ton of code to write at times, especially when the files are just 1:1.

heavyk commented 8 years ago

hey dude, this is a one-liner so I did it just now

fskreuz commented 8 years ago

I thought I'd leave it out here for a bit while longer. Was thinking

heavyk commented 8 years ago

null is not a valid return value. inside of a file, you could have the string "null" and you would see those letters inside. but, like node dictates, a file can either be a utf-8 encoded string or a buffer. right now gobble only checks to see if it's a string, but it should also check to see if a buffer is returned. (I'll add that to the PR shortly) if you wanted a null value in your file, you would pass it a zero-filled buffer.

anyway, I thought null was a good idea to skip the file. it is useful.

Rich-Harris commented 8 years ago

In 0.11.0 :+1: