Gathering detailed insights and metrics for gulp-cheerio
Gathering detailed insights and metrics for gulp-cheerio
Gathering detailed insights and metrics for gulp-cheerio
Gathering detailed insights and metrics for gulp-cheerio
npm install gulp-cheerio
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
98 Stars
62 Commits
13 Forks
7 Watching
3 Branches
6 Contributors
Updated on 21 Nov 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
9.2%
3,134
Compared to previous day
Last week
10.6%
18,778
Compared to previous week
Last month
28.6%
80,226
Compared to previous month
Last year
-25.9%
804,164
Compared to previous year
3
This is a plugin for gulp which allows you to manipulate HTML and XML files using cheerio.
There are two ways to use gulp-cheerio
: synchronous and asynchronous. See
the following usage examples:
1var gulp = require('gulp'), 2 cheerio = require('gulp-cheerio'); 3 4gulp.task('sync', function() { 5 return gulp 6 .src(['src/*.html']) 7 .pipe( 8 cheerio(function($, file) { 9 // Each file will be run through cheerio and each corresponding `$` will be passed here. 10 // `file` is the gulp file object 11 // Make all h1 tags uppercase 12 $('h1').each(function() { 13 var h1 = $(this); 14 h1.text(h1.text().toUpperCase()); 15 }); 16 }), 17 ) 18 .pipe(gulp.dest('dist/')); 19}); 20 21gulp.task('async', function() { 22 return gulp 23 .src(['src/*.html']) 24 .pipe( 25 cheerio(function($, file, done) { 26 // The only difference here is the inclusion of a `done` parameter. 27 // Call `done` when everything is finished. `done` accepts an error if applicable. 28 done(); 29 }), 30 ) 31 .pipe(gulp.dest('dist/')); 32});
Additional options can be passed by passing an object as the main argument
with your function as the run
option:
1var gulp = require('gulp'), 2 cheerio = require('gulp-cheerio'); 3 4gulp.task('sync', function() { 5 return gulp 6 .src(['src/*.html']) 7 .pipe( 8 cheerio({ 9 run: function($, file) { 10 // Each file will be run through cheerio and each corresponding `$` will be passed here. 11 // `file` is the gulp file object 12 // Make all h1 tags uppercase 13 $('h1').each(function() { 14 var h1 = $(this); 15 h1.text(h1.text().toUpperCase()); 16 }); 17 }, 18 }), 19 ) 20 .pipe(gulp.dest('dist/')); 21}); 22 23gulp.task('async', function() { 24 return gulp 25 .src(['src/*.html']) 26 .pipe( 27 cheerio({ 28 run: function($, file, done) { 29 // The only difference here is the inclusion of a `done` parameter. 30 // Call `done` when everything is finished. `done` accepts an error if applicable. 31 done(); 32 }, 33 }), 34 ) 35 .pipe(gulp.dest('dist/')); 36});
If you want to use custom parser options simply use the parserOptions
option:
1cheerio({ 2 run: function() {}, 3 parserOptions: { 4 // Options here 5 }, 6});
When the xmlMode option is set to true cheerio's $.xml() method will be used to render:
1cheerio({ 2 run: function() {}, 3 parserOptions: { 4 xmlMode: true, 5 }, 6});
This module includes cheerio version 0.*
. If you want to use your own
special build / version of cheerio
, you can pass it in as an option:
1cheerio({ 2 cheerio: require('my-cheerio'), // special version of `cheerio` 3});
As of version 0.4.0
the parsed $
object returned from cheerio.load(...)
is cached to gulp's file
object as file.cheerio
. gulp-cheerio
will look
for file.cheerio
before attempting to use cheerio.load(...)
. This means
that if you use gulp-cheerio
multiple times in the same stream or with
another plugin that supports caching cheerio in this fashion (such as
gulp-svgstore
) each file will only be parsed once.
The MIT License
Copyright (c) 2014 Kenneth Powers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
Score
Last Scanned on 2024-11-25
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