Visit gulp-newy.com for screen shots, examples, and more
Install
$ npm install --save-dev gulp-newy
Usage
Using a single callback function, you have complete control.
var newy = ;
Result
-------------------- Newy Message ------------------
File [source filename] is new/newer then [destination filename returned from your callback]
----------------------------------------------------
Example Callback Functions
Many to one comparison
Compare less
files in /home/one/github/foo/app/css/*.less
against single file /home/one/github/foo/compiled/css/application.css
var newy = ;var path = ; { // Newy gives projectDir arg wich is '/home/one/github/foo/` var compareFileAgainst = "compiled/css/application.css"; var destinationFile = path; // distinationFile returned will be /home/one/github/foo/compiled/css/application.css return destinationFile;}// all *.less files will be compared against// /home/one/github/foo/compiled/css/application.css gulp;
One to one comparison
Compare coffee
script files in /home/one/github/foo/app/js/*.coffee
against
compiled Javascript
files in /home/one/github/foo/compiled/js/*.js
- note: child directories and files will be globed with no issues
var newy = ;var path = ; { // newy gives projectDir arg wich is '/home/one/github/foo/` var stripPath = "app"; var destDir = "compiled/js"; var newSuffix = ".js" var re = "^\/.*"+stripPath+"\/"; var relativeSourceFile = absSrcFile; var destinationFile = path; destinationFile = destination + newSuffix; // srcFile is error.service.coffee // destination file returned is // /home/one/github/foo/compiled/js/fooBar/services/error-services/error.service.js return destinationFile;} gulp;
FAQs
- It's ok if directory in the absolute path doesn't exist, but newy will let you know as a courtesy warning in case it was unintentional.
- If there is no destination file, newy will automatically count file as new and pipe it through as any other file that is newer.
- Always be sure to return the destination file with a absolute path, not a relative path.
projectDir
is given to you for this.
Notes
- Why doesn't gulp-newy use options instead of a callback? Because 'one size does not fit all'. I have found with other modules of the same type I was restricted and could not do what I needed.
- Why aren't you using batch style operations? Think about this stream as a gas pump filling your car....do you want a steady stream or do you want a bottle neck of operation end results all released at once which will still end up a steady stream?
- Why aren't you using node
process.nextTick
orsetImmediate
for async-like behavior? The majority of operations here are I/O operations. This means they are natively non-blocking. Using these apis would only gaurantee that each job runs next in the event queue...which is unnecessary. If you really wanted to set this behavior, it can be done in the gulp wraped task. - What does all this mean? A code free of overhead software gives you less issues and bugs. Think of food that is orgranic and more healthy.