
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
gulp-flatten
Advanced tools
Remove or replace relative path for files (gulp v3).
npm install gulp-flatten
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
Type: String
Default: ''
Relative path for file.
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
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.
MIT
FAQs
remove or replace relative path for files
The npm package gulp-flatten receives a total of 62,362 weekly downloads. As such, gulp-flatten popularity was classified as popular.
We found that gulp-flatten demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.