All Projects → armed → Gulp Flatten

armed / Gulp Flatten

Licence: mit
Gulp plugin: remove or replace relative paths for files

Programming Languages

javascript
137047 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Flatten

gulp-convert-encoding
Plugin for gulp to convert files from one encoding to another.
Stars: ✭ 15 (-85.29%)
Mutual labels:  gulp, gulp-plugin
Gulp Ftp
[DEPRECATED] Upload files to an FTP-server
Stars: ✭ 100 (-1.96%)
Mutual labels:  gulp, gulp-plugin
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (-25.49%)
Mutual labels:  gulp, gulp-plugin
gulp-golang
gulp plugin for golang projects
Stars: ✭ 13 (-87.25%)
Mutual labels:  gulp, gulp-plugin
Gulp Require Tasks
Splits Gulpfile into multiple individual files
Stars: ✭ 51 (-50%)
Mutual labels:  gulp, gulp-plugin
anyfs
Portable file system for Node
Stars: ✭ 17 (-83.33%)
Mutual labels:  gulp, gulp-plugin
Gulp Pug
Gulp plugin for compiling Pug templates
Stars: ✭ 512 (+401.96%)
Mutual labels:  gulp, gulp-plugin
gulp-recess
[DEPRECATED] Lint CSS and LESS with RECESS
Stars: ✭ 42 (-58.82%)
Mutual labels:  gulp, gulp-plugin
Generator Gulp Plugin Boilerplate
Scaffold out a Gulp plugin boilerplate
Stars: ✭ 46 (-54.9%)
Mutual labels:  gulp, gulp-plugin
Gulp Jsonlint
🔍 jsonlint plugin for Gulp
Stars: ✭ 26 (-74.51%)
Mutual labels:  gulp, gulp-plugin
Gulp Ngmin
[DEPRECATED] Pre-minify AngularJS apps with ngmin
Stars: ✭ 89 (-12.75%)
Mutual labels:  gulp, gulp-plugin
Gulp Develop Server
Development assistant for node.js server by gulp
Stars: ✭ 72 (-29.41%)
Mutual labels:  gulp, gulp-plugin
gulp-iife
A Gulp plugin for wrapping JavaScript code in IIFEs.
Stars: ✭ 39 (-61.76%)
Mutual labels:  gulp, gulp-plugin
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-78.43%)
Mutual labels:  gulp, gulp-plugin
gulp-tinypng-compress
TinyPNG API wrapper for compressing PNG & JPG images
Stars: ✭ 49 (-51.96%)
Mutual labels:  gulp, gulp-plugin
Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (+364.71%)
Mutual labels:  gulp, gulp-plugin
Gulp Html Replace
Replace build blocks in HTML. Like useref but done right.
Stars: ✭ 222 (+117.65%)
Mutual labels:  gulp, gulp-plugin
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-81.37%)
Mutual labels:  gulp, gulp-plugin
Gulp Angular Templatecache
Concatenates and registers AngularJS templates in the $templateCache.
Stars: ✭ 530 (+419.61%)
Mutual labels:  gulp, gulp-plugin
Gulp Json Editor
A gulp plugin to edit JSON objects
Stars: ✭ 55 (-46.08%)
Mutual labels:  gulp, gulp-plugin

gulp-flatten NPM version Build Status

Remove or replace relative path for files (gulp v3).

Install

npm install gulp-flatten

Usage

Example source directory with bower compoments:

├── angular
│   ├── README.md
│   ├── angular-csp.css
│   ├── angular.js
│   ├── angular.min.js
│   └── bower.json
├── angular-route
│   ├── README.md
│   ├── angular-route.js
│   ├── angular-route.min.js
│   ├── angular-route.min.js.map
│   └── bower.json
├── angular-sanitize
│   ├── README.md
│   ├── angular-sanitize.js
│   ├── angular-sanitize.min.js
│   ├── angular-sanitize.min.js.map
│   └── bower.json
└── bootstrap
    ├── DOCS-LICENSE
    ├── LICENSE
    ├── LICENSE-MIT
    ├── README.md
    ├── bower.json
    └── dist
        ├── css
        │   ├── bootstrap-theme.css
        │   ├── bootstrap-theme.min.css
        │   ├── bootstrap.css
        │   └── bootstrap.min.css
        ├── fonts
        │   ├── glyphicons-halflings-regular.eot
        │   ├── glyphicons-halflings-regular.svg
        │   ├── glyphicons-halflings-regular.ttf
        │   └── glyphicons-halflings-regular.woff
        └── js
            ├── bootstrap.js
            └── bootstrap.min.js

By default gulp stores files with it's relative paths. To copy all minified javascript files from bower_components to build folder without relative paths:

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

gulp.src('bower_components/**/*.min.js')
  .pipe(flatten())
  .pipe(gulp.dest('build/js'));

Result will be list of all .min.js files inside build/js dir:

build
└── js
    ├── angular-route.min.js
    ├── angular-sanitize.min.js
    ├── angular.min.js
    └── bootstrap.min.js

Options

flatten(options)

options.newPath

Type: String
Default: ''

Relative path for file.

options.includeParents

Type: Number or Array of two numbers

If passed in as positive number, it will include the number of top-level parents in the output. Using this code:

gulp.src(['bower_components/**/*.css'])
  .pipe(flatten({ includeParents: 1} ))
  .pipe(gulp.dest('build/'));

will create this structure (from sample directory tree above):

└── bootstrap
    ├── bootstrap-theme.css
    ├── bootstrap-theme.min.css
    ├── bootstrap.css
    └── bootstrap.min.css

If passed in as negative number, it will include the number of bottom-level parents in the output. Using this code:

gulp.src(['bower_components/**/*.css'])
  .pipe(flatten({ includeParents: -1} )) //or indludeParents: [0, 1]
  .pipe(gulp.dest('build/'));

will create this structure:

└── css
    ├── bootstrap-theme.css
    ├── bootstrap-theme.min.css
    ├── bootstrap.css
    └── bootstrap.min.css

If passes as array of two numbers, both parents from top and bottom will be kept in resulting path of a file.

gulp.src(['bower_components/**/*.css'])
  .pipe(flatten({ includeParents: [1, 1]} ))
  .pipe(gulp.dest('build/'));

will create this structure:

└── bootstrap
    └── css
        ├── bootstrap-theme.css
        ├── bootstrap-theme.min.css
        ├── bootstrap.css
        └── bootstrap.min.css

options.subPath

Type: Number or Array of two Numbers [begin, end]

This options applies Array.slice to the array of path elements and allows you to receive a subsequences of the path.

gulp.src(['bower_components/**/*.css'])
  .pipe(flatten({ subPath: [1, 1]} ))
  .pipe(gulp.dest('build/'));

This as an example would flatten top1/top2/bottom2/bottom1/file.txt to top2/file.txt.

[1, -1] would flatten top1/top2/bottom2/bottom1/file.txt to top2/bottom2/file.txt.

Please refer to the Array.slice documentation for a detailed description.

! If you're using both options.includeParents combined with options.subPath please note that options.includeParents is applied first.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected]