You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

gulp-append

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-append

Append a file the easy way

0.3.4
latest
Source
npmnpm
Version published
Weekly downloads
222
4.23%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-append Build Status

An gulp plugin for writing .pipe 'data' to a file.

Install

$ npm install --save-dev gulp-append

Usage

Default usage

var gulp = require('gulp');
var append = require('gulp-append');

gulp.task('default', function () {
	return gulp.src('src/file.json')
		.pipe(append());
});

Using a custom destination

var gulp = require('gulp');
var append = require('gulp-append');

gulp.task('default', function () {
	return gulp.src('src/file.json')
		.pipe(append('some/path/appended-file.json'));
});

Using tranform

var gulp = require('gulp');
var append = require('gulp-append');
var nameFromPath = require('name-from-path');

gulp.task('append:transform', () => {
  return gulp.src(
    'README.md'
  ).pipe(append({
      transform: {
        path: function(file) {
          return String(file.path)
        },
        name: function(file) {
          return nameFromPath(file, true);
        }
      }
    }
  ));
});

Wrapping it all together

var gulp = require('gulp');
var append = require('gulp-append');
var nameFromPath = require('name-from-path');

gulp.task('append:transform', () => {
  return gulp.src(
    'README.md'
  ).pipe(append('some/path/to/file.json', {
    transform: {
      path: function(file) {
        return String(file.path)
      },
      name: function(file) {
        return nameFromPath(file, true);
      }
    }
  }));
});

API

options

append(destination)

Type: string
Default: appended.json

The destination to write to.

append('some-file.json');

append(opts) - json

Type: boolean
Default: false

Wether or not the destination should be handled as json.

append({json: true});

append(opts) - named

Type: boolean
Default: false

Wether or not to name the items.

*** creates an named object when true (checkout the transform option to learn how to set an custom name)***

append({named: true});

append(opts) - transform

Type: object
Default: undefined

Transform the file to your likes.

append({
	transform: {
	  path: function(file) {
			return String(file.path);
	  },
		info: function(file) {
			return 'some info ...';
		}
	}
});

License

MIT © Glenn Vandeuren

Keywords

gulp-plugin

FAQs

Package last updated on 17 Oct 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