Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-transform

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-transform

Gulp plugin for performing arbitrary transformations on the contents of files.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9K
increased by17.03%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-transform

Version License Build Coverage Dependencies

Gulp plugin for applying arbitrary transformations to the contents of files. Useful for incorporating non-gulp functions and modules into your pipeline. Files may be in streaming mode or buffer mode.

Install

Install via npm:

npm install --save-dev gulp-transform

Example

Source file (caesar.txt):

I am constant as the northern star...

Transform task:

const gulp = require('gulp');
const transform = require('gulp-transform');

// Repeat contents three times and prepend filename.
function transformFn(contents, file) {
  return [file.path, contents, contents, contents].join('\n');
}

gulp.task('silly-task', function() {
  return gulp.src('/path/to/src/**/*.txt')
    .pipe(transform(transformFn)) // Apply transform.
    .pipe(gulp.dest('/path/to/dest'));
});

Destination file:

/path/to/src/caesar.txt
I am constant as the northern star...
I am constant as the northern star...
I am constant as the northern star...

API

The package exports a single plugin function that takes a callback and an optional options object. The callback is invoked once per file. The contents of the file are passed to the callback and replaced by the return value.

Usage
transform(transformFn, [options])
Param Type Details
transformFn Function Function that transforms the contents of each file. Invoked with the following arguments:
  • contents (Buffer|String) The contents of the file. Will be a Buffer unless otherwise specified.
  • file (File) The vinyl file object whose contents are to be transformed. Useful for getting metadata about the file, such as its name or path.
The return value will replace the file's contents and must be either a String or a Buffer.
options
(optional)
Object Options to modify the behavior of the plugin.
  • encoding (String) Casts contents to a string with the specified encoding before it is passed to transformFn. If no encoding is specified, contents will be passed as a Buffer.
  • thisArg (*) Determines the value of this within transformFn. Defaults to undefined.

License

Copyright © 2016 Akim McMath. Licensed under the MIT License.

Keywords

FAQs

Package last updated on 16 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc