├── .editorconfig ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── index.js ├── package.json └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = tab 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [{package.json,bower.json}] 20 | indent_style=space 21 | indent_size=2 22 | 23 | [*.md] 24 | trim_trailing_whitespace = false 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /node_modules 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 4, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "maxdepth": 2, 22 | "maxcomplexity": 10, 23 | "globals": { 24 | "angular": false 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 - 2018-03-28 4 | - Upgrade Vinyl for Node 8 LTS compatibility ([#15](https://github.com/urish/gulp-add-src/pull/15)) 5 | 6 | ## 0.2.0 - 2014-11-08 7 | 8 | - Add `append()` and `prepend()` methods for controlling added files position ([#4](https://github.com/urish/gulp-add-src/pull/4), contributed by [CWSpear](https://github.com/CWSpear)) 9 | - Be more specific in defining dependencies ([#3](https://github.com/urish/gulp-add-src/pull/3), contributed by [CWSpear](https://github.com/CWSpear)) 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gulp-add-src 2 | ============ 3 | 4 | Add more 'src' files at any point in the pipeline 5 | 6 | Copyright (C) 2014, Uri Shaked and contributors 7 | 8 | [![Build Status](https://travis-ci.org/urish/gulp-add-src.png?branch=master)](https://travis-ci.org/urish/gulp-add-src) 9 | 10 | Installation 11 | ------------ 12 | 13 | `npm install gulp-add-src --save-dev` 14 | 15 | Usage 16 | ----- 17 | Works like `gulp.src`, but you can put it anywhere in your pipeline and it will append the given files 18 | to the pipeline. 19 | 20 | Example: 21 | ```js 22 | var gulp = require('gulp'); 23 | var addsrc = require('gulp-add-src'); 24 | var coffee = require('gulp-coffee'); 25 | var uglify = require('gulp-uglify'); 26 | 27 | gulp.task('build', function () { 28 | return gulp.src('files/coffee/*.coffee') // start with the .coffee files in the project 29 | .pipe(coffee()) // compiles coffee script 30 | .pipe(addsrc('files/js/*.js')) // we use addsrc to add our .js files to the mix 31 | .pipe(uglify()) // we minify everything 32 | .pipe(gulp.dest('dist')); // and write to dist 33 | }); 34 | ``` 35 | 36 | If you want add SRC to begining of the SRC array, you can use `addsrc.prepend`. 37 | Or if you want to add SRC to end of the SRC array, you can use `addsrc.append`. 38 | Respectively instead of addsrc. 39 | 40 | Example use addsrc.append and addsrc.prepend: 41 | ```js 42 | var gulp = require('gulp'); 43 | var addsrc = require('gulp-add-src'); 44 | var coffee = require('gulp-coffee'); 45 | var uglify = require('gulp-uglify'); 46 | 47 | gulp.task('build.angular', function () { 48 | return gulp.src('files/coffee/*.coffee') // start with the .coffee files in the project 49 | .pipe(coffee()) // compiles coffee script 50 | .pipe(addsrc.prepend('files/js/constants.js')) // we use `addsrc.prepend` to add our .js files to begining of the SRC array 51 | .pipe(addsrc.append('files/js/conflict.js')) // we use `addsrc.append` to add our .js files to end of the SRC array 52 | .pipe(uglify()) // we minify everything 53 | .pipe(gulp.dest('dist')); // and write to dist 54 | }); 55 | ``` 56 | 57 | As an example, this would be useful if you wanted to merge your `bower` scripts with your app scripts. You'd need your `bower` scripts to maintain their order (the `bower` scripts themselves) and make sure they come before your app scripts. In this case, you'd use `addsrc.prepend`. 58 | 59 | Because of the unpredicabilty of `addsrc` alone, it's recommended to use one of the append/prepend variants. The original is only left in place for legacy reasons. 60 | 61 | License 62 | ---- 63 | 64 | Released under the terms of MIT License: 65 | 66 | Permission is hereby granted, free of charge, to any person obtaining 67 | a copy of this software and associated documentation files (the 68 | 'Software'), to deal in the Software without restriction, including 69 | without limitation the rights to use, copy, modify, merge, publish, 70 | distribute, sublicense, and/or sell copies of the Software, and to 71 | permit persons to whom the Software is furnished to do so, subject to 72 | the following conditions: 73 | 74 | The above copyright notice and this permission notice shall be 75 | included in all copies or substantial portions of the Software. 76 | 77 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 78 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 79 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 80 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 81 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 82 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 83 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 84 | 85 | 86 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* gulp-add-src / v1.0.0 / (c) 2014 Uri Shaked / MIT Licence */ 2 | 3 | 'use strict'; 4 | var through = require('through2'); 5 | var streamqueue = require('streamqueue'); 6 | var es = require('event-stream'); 7 | var vinyl = require('vinyl-fs'); 8 | 9 | function prepend() { 10 | var pass = through.obj(); 11 | return es.duplex(pass, streamqueue({ objectMode: true }, vinyl.src.apply(vinyl.src, arguments), pass)); 12 | } 13 | 14 | function append() { 15 | var pass = through.obj(); 16 | return es.duplex(pass, streamqueue({ objectMode: true }, pass, vinyl.src.apply(vinyl.src, arguments))); 17 | } 18 | 19 | var addSrc = function () { 20 | var pass = through.obj(); 21 | return es.duplex(pass, es.merge(vinyl.src.apply(vinyl.src, arguments), pass)); 22 | }; 23 | 24 | addSrc.append = append; 25 | addSrc.prepend = prepend; 26 | 27 | module.exports = addSrc; 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-add-src", 3 | "version": "1.0.0", 4 | "description": "Add more 'src' files at any point in the pipeline (gulp plugin)", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node_modules/.bin/mocha" 8 | }, 9 | "files": [ 10 | "index.js" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/urish/gulp-add-src" 15 | }, 16 | "keywords": [ 17 | "gulp", 18 | "gulpplugin", 19 | "gulpfriendly", 20 | "pipeline" 21 | ], 22 | "author": "Uri Shaked", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/urish/gulp-add-src/issues" 26 | }, 27 | "dependencies": { 28 | "event-stream": "~3.1.5", 29 | "streamqueue": "^0.1.1", 30 | "through2": "~0.4.1", 31 | "vinyl-fs": "~3.0.2" 32 | }, 33 | "devDependencies": { 34 | "mocha": "^1.18.2", 35 | "gulp": "^3.6.2" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 'use strict'; 3 | 4 | var assert = require('assert'); 5 | var join = require('path').join; 6 | var gulp = require('gulp'); 7 | var addsrc = require('./index'); 8 | 9 | describe('gulp-add-src', function () { 10 | it('should add files to an existing stream', function (done) { 11 | var stream = gulp.src(['index.js', 'test.js']) 12 | .pipe(addsrc(['package.json', 'README.md'])); 13 | 14 | var allFiles = []; 15 | stream.on('error', done); 16 | stream.on('data', function (file) { 17 | allFiles.push(file.path); 18 | }); 19 | stream.on('end', function() { 20 | // they just need to be the same, order doesn't matter! 21 | assert.deepEqual(allFiles.sort(), [ 22 | join(__dirname, 'index.js'), 23 | join(__dirname, 'test.js'), 24 | join(__dirname, 'package.json'), 25 | join(__dirname, 'README.md') 26 | ].sort()); 27 | done(); 28 | }); 29 | }); 30 | 31 | it('should append files to an existing stream in order', function (done) { 32 | var stream = gulp.src(['index.js', 'test.js']) 33 | .pipe(addsrc.append(['package.json', 'README.md'])); 34 | 35 | var allFiles = []; 36 | stream.on('error', done); 37 | stream.on('data', function (file) { 38 | allFiles.push(file.path); 39 | }); 40 | stream.on('end', function() { 41 | // they just need to be the same, order doesn't matter! 42 | assert.deepEqual(allFiles, [ 43 | join(__dirname, 'index.js'), 44 | join(__dirname, 'test.js'), 45 | join(__dirname, 'package.json'), 46 | join(__dirname, 'README.md') 47 | ]); 48 | done(); 49 | }); 50 | }); 51 | 52 | it('should append files to an existing stream in order', function (done) { 53 | var stream = gulp.src(['index.js', 'test.js']) 54 | .pipe(addsrc.append(['package.json', 'README.md'])); 55 | 56 | var allFiles = []; 57 | stream.on('error', done); 58 | stream.on('data', function (file) { 59 | allFiles.push(file.path); 60 | }); 61 | stream.on('end', function() { 62 | // they just need to be the same, order doesn't matter! 63 | assert.deepEqual(allFiles.sort(), [ 64 | join(__dirname, 'package.json'), 65 | join(__dirname, 'README.md'), 66 | join(__dirname, 'index.js'), 67 | join(__dirname, 'test.js') 68 | ].sort()); 69 | done(); 70 | }); 71 | }); 72 | }); 73 | --------------------------------------------------------------------------------