Gathering detailed insights and metrics for gulp-concat-flatten
Gathering detailed insights and metrics for gulp-concat-flatten
Gathering detailed insights and metrics for gulp-concat-flatten
Gathering detailed insights and metrics for gulp-concat-flatten
A Gulp plugin to recursively flatten directories and concatenate the files within
npm install gulp-concat-flatten
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
35 Commits
1 Watchers
12 Branches
1 Contributors
Updated on Feb 01, 2022
Latest Version
3.0.1
Package Id
gulp-concat-flatten@3.0.1
Unpacked Size
16.54 kB
Size
5.73 kB
File Count
5
NPM Version
6.13.3
Node Version
8.12.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
is a Gulp plugin that concatenates files based on their directory structure. Starting at a base directory of your choice, it recursively flattens out subdirectories and concatenates the files within these. Files in the base directory will get copied without concatenation.
To install gulp-concat-flatten
as a development dependency, simply run:
1npm install --save-dev gulp-concat-flatten
Add it to your gulpfile.js
and use it like this:
1const gulp = require('gulp'); 2const concat = require('gulp-concat-flatten'); 3const sort = require('gulp-sort'); 4 5gulp.src('path/**/*.txt') 6 .pipe(sort()) // Recommendation, see below 7 .pipe(concat('path/to/assets', 'txt', {'newLine': '\n'})) 8 .pipe(gulp.dest('out'));
Running the shown task on a source file structure like this:
path
`-- to
|-- 00_outside.txt
`-- assets
|-- 01_first.txt
|-- 02_second
| |-- 01_second_first.txt
| |-- 02_second_second
| | `-- second_second_first.txt
| `-- 03_second_third.txt
`-- 03_third.txt
would result in:
out
|-- 01_first.txt
|-- 02_second.txt
`-- 03_third.txt
In detail,
path/to/00_outside.txt
would be skipped as it's not contained in the base directory path/to/assets
,path/to/assets/01_first.txt
and path/to/assets/03_third.txt
would be copied over without concatenation,path/to/assets/02_second
would be recursively concatenated and appended with the file extension ".txt"
.Generally, I recommend sorting the source files via gulp-sort prior to piping them through concat()
. This way you can reliably control their order for concatenation using file and directory names.
As of version 1.0, you can also let concat()
control the resource order based on dependencies:
path
`-- to
|-- .dependencies.json
`-- assets
|-- 01_first.txt
|-- 02_second
| |-- .dependencies.json
| |-- 01_second_first.txt
| `-- 02_second_second.txt
`-- 03_third.txt
When flattening the directory path/to/assets/02_second
, concat()
will read path/to/assets/02_second/.dependencies.json
and build a dependency graph based on the instructions inside that file. It will also collect and merge all .dependecies.json
files in parent directories. The format for .dependencies.json
files is a follows:
1{ 2 "*.txt": [ 3 "path/to/assets/03_third.txt", 4 "path/to/another/asset", 5 ] 6}
The example tells concat()
the following:
Whenever the resulting filename of the flattened
02_second
directory is going to match the glob pattern*.txt
, then register the two dependenciespath/to/assets/03_third.txt
andpath/to/another/asset
for this resource . (The dependencypath/to/another/asset
will be ignored as no such resource exists in the example.)
Given the above file structure, concat()
will result in the following resource order:
path/to/assets/03_third.txt
: no dependency, but there is a dependent resources (02_second.txt
), so this has to come beforepath/to/assets/02_second.txt
: concatenated folder; depends on 03_third.txt
path/to/assets/01_first.txt
: no dependency, added at the endBy binding the dependency set to a glob pattern (*.txt
) you can express multiple sets for different result file types (e.g. CSS and JavaScript files).
/**
* Concatenation by directory structure
*
* @param {String} base Base directory
* @param {String} ext Optional: File extension
* Will be used as file extension for concatenated directories
* @param {Object} opt Optional: Options, defaulting to:
* {
* newLine: "\n" // Concatenation string, may be empty
* }
*/
concat(base, ext, opt);
NOTE that the base
argument also accepts a glob pattern to match multiple base directories.
Please refer to the changelog for a complete release history.
Copyright © 2019 Joschi Kuphal joschi@kuphal.net / @jkphl.
gulp-concat-flatten is licensed under the terms of the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/23 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
47 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More