Using a Gulp Plugin

Natron should be compatible with the majority of Gulp plugins out there, since it's also using Vinyl for file transformations.

Examples

gulp-uglify

The following snippet shows how the plugin is supposed to be used with Gulp.

var gulp = require("gulp");
var uglify = require("gulp-uglify");
 
gulp.task("minify", function() {
  return (gulp.src("src/**/*.js")
    .pipe(uglify())
    .pipe(gulp.dest("dist"))
  );
});

In order to use it with Natron we need to install the vinyl-fs package or simple use the natron-vinyl module which includes some Vinyl related utilities like the file system adapter and the file transformer.

So the Natronfile would look similar to this:

import {src, dest} from "natron-vinyl";
import uglify from "gulp-uglify";

export function minify() {
  return (src("src/**/*.js")
    .pipe(uglify())
    .pipe(dest("dist"))
  );
}

gulp-debug

With gulp-debug files that are currently in the transformation pipeline can be listed for debugging purposes. The usage with Natron is quite similiar:

import {src, dest} from "natron-vinyl";
import debug from "gulp-debug";

export function doSomething() {
  return (src("src/**/*.js")
    .pipe(debug())
    .pipe(dest("dist"))
  );
}

However a more lightweight approach to list all files in the pipeline would be to create a simple transformer:

import {src, dest, transformer} from "natron-vinyl";

let FileLogger = transformer((file) => {
  console.log(file.path);
  return file;
});

export function doSomething() {
  return (src("src/**/*.js")
    .pipe(new FileLogger())
    .pipe(dest("dist"))
  );
}