Custom targets / running arbitrary code

You make

can define custom targets that have nothing to do with the actual code on which they operate, in the sense that they are agnostic.

release_sortof:
         @echo packaging release...
         tar czf release.tar.gz file1 file2 file3
         ls /dev/null
         ls /dev/stderr
         ls /dev/stdout

      

I know the above example is terrible, but the point I'm trying to illustrate is that the code in the target release_sortof

is independent of the fact that my project uses code written in C, for example; and is independent of me using Make-ins such as foreach

.


Is there a way to work with / <INSERT-NAME>script

without javascript files using all the available plugins for gulp? As in, I could draw my coffee pot with by coffeelint

calling the module directly coffeelint

:

var gulp = require('gulp')
  , coffeelint = require('coffeelint')
  ;

gulp.task('lint', function() {
   /* run coffeelint on source files */
});

      

Or can it only be done with plugins?


Another example would be to run arbitrary code like this:

var spawn = require('child_process').spawn;
gulp.task('blue', function() {
  var child = spawn('ls');
  /* do stuff with spawned child process */
});

      

+3


source to share


1 answer


I do things like this for browserify

with vinyl-source-stream

- basically letting you use the library as it is, and without using plugins gulp-*

.

var browserify = require('browserify'),
    gulp = require('gulp'),
    source = require('vinyl-source-stream'),
    stringify = require('stringify'),
    plumber = require('gulp-plumber'),
    config = require('../config').scripts;

gulp.task('browserify', function () {
    return browserify(config.app)
        .transform(stringify(['.html']))
        .bundle()
        .pipe(plumber())
        .pipe(source('bundle.js'))
        .pipe(gulp.dest(config.dest));
});

      

Heres the npm - https://www.npmjs.com/package/vinyl-source-stream



Use plain text streams at the beginning of your gulp or vinyl piping for better compatibility with existing npm streaming ecosystems.

Maybe this will help you?

0


source







All Articles