npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-append-prepend-dir

v1.0.2

Published

Append or prepend the file content with the corresponding file in a dir

Downloads

11

Readme

gulp-append-prepend-dir

Append or prepend the file content with the corresponding file in a dir

Build Status Coverage Status Dependency Status devDependency Status npm npm

Install

$ npm install gulp-append-prepend-dir --save-dev

Usage

Like 'gulp-append-prepend', this plugin loads content of a file from the file system and append, prepend, or insert the loaded content into the streamed files (pipe). However, this plugin works in 'relative' mode by default, loads the content from not a fixed file (like gulp-append-prepend), but a file with the same relative path of the streamed file from a given base dir. For example, if the current streamed file is sourced from 'src/*.txt', whereas the 'relative' property (see gulp Vinyl API) is 'a.txt', then when the base dir is given 'dest/', the plugin loads contents to be appended/prepended/inserted from 'dest/a.txt'.

This plugin can be used with slush to append various contents from a template dir to the existing files in the working dir, whereas the to be appended contents are in the template dir with the same relative path and file name with the corresponding files in the working dir.

const gulp = require('gulp');
const gapd = require('gulp-append-prepend-dir');

gulp.task('myTask', () => {
  gulp.src(['srcDir/**.txt'])
    .pipe(gapd.append('./destDir'))
    .pipe(gulp.dest('destDir'));
});

All functions accept an optional object parameter as options. Defaults are:

{
  ignoreMissingFile: true,
  separator:'\n',
  useRelative:true,
  ignoreMissingMark: false
}

ignoreMissingFile: default true, if the file from which content is to be appended/prepended/inserted cannot be found, simply ignore and does not throw an error.

separator: default new line

useRelative: default true, use 'relative' mode, where the given dir is used as the base dir and full path of the file to load is calculated from the base dir and the 'relative' property of the streamed file. If useRelative is specified false, use the given dir as full path to a file and append/prepend/insert the content of this file to all streamed files.

ignoreMissingMark: when the content is to be inserted before or after a mark and when the mark is missing, ignore and does not throw an error. Default false.

The exported functions are:

append(dir:string, opt:options={})
prepend(dir:string, opt:options={})

Return a node stream Transform that append contents read from file in dir (or file specified by dir, depending on relative mode).

insertAfter(dir:string, mark:string, opt:options={})
insertBefore(dir:string, mark:string, opt:options={})

Return a node stream Transform that insert the contents read from file in (or specified by) dir after/before the mark string in the streamed content.

Also check the unit test for example usages.

Development

Tests

Run the unit tests with mocha:

$ npm run test

Calculate the coverage with Istanbul:

$ npm run cover

Versioning

To keep better organization of releases we follow the Semantic Versioning 2.0.0 guidelines.

Contributing

Find on our issues the next steps of the project ;) Want to contribute? Follow these recommendations.

History

See Releases for detailed changelog.

License

MIT License © bingtimren