+12
-10
| #!/usr/bin/env node | ||
| 'use strict'; | ||
| var fs = require('fs'); | ||
| var argv = require('minimist')(process.argv.slice(2)); | ||
| var pkg = require('./package.json'); | ||
| var oust = require('./'); | ||
| const fs = require('fs'); | ||
| const minimist = require('minimist'); | ||
| const pkg = require('./package.json'); | ||
| const oust = require('.'); | ||
| const argv = minimist(process.argv.slice(2)); | ||
| function printHelp() { | ||
@@ -22,3 +24,3 @@ console.log([ | ||
| console.log(pkg.version); | ||
| return; | ||
| process.exit(0); | ||
| } | ||
@@ -28,9 +30,9 @@ | ||
| printHelp(); | ||
| return; | ||
| process.exit(0); | ||
| } | ||
| var file = argv._[0]; | ||
| var type = argv._[1]; | ||
| const file = argv._[0]; | ||
| const type = argv._[1]; | ||
| fs.readFile(file, function (err, data) { | ||
| fs.readFile(file, (err, data) => { | ||
| if (err) { | ||
@@ -37,0 +39,0 @@ console.error('Error opening file:', err.message); |
+16
-15
@@ -18,6 +18,6 @@ /*! | ||
| */ | ||
| 'use strict'; | ||
| var cheerio = require('cheerio'); | ||
| var types = { | ||
| const cheerio = require('cheerio'); | ||
| const types = { | ||
| stylesheets: { | ||
@@ -36,4 +36,4 @@ selector: 'link[rel="stylesheet"]', | ||
| preload: { | ||
| selector: 'link[rel="preload"][as="style"]', | ||
| attribute: 'href' | ||
| selector: 'link[rel="preload"][as="style"]', | ||
| attribute: 'href' | ||
| }, | ||
@@ -50,3 +50,3 @@ links: { | ||
| module.exports = function (src, type) { | ||
| module.exports = (src, type) => { | ||
| if (!src || !type) { | ||
@@ -56,6 +56,6 @@ throw new Error('`src` and `type` required'); | ||
| var chosenType = types[type]; | ||
| var $ = cheerio.load(src); | ||
| const chosenType = types[type]; | ||
| const $ = cheerio.load(src); | ||
| return $(chosenType.selector).map(function (i, el) { | ||
| return $(chosenType.selector).map((i, el) => { | ||
| return $(el).attr(chosenType.attribute); | ||
@@ -70,12 +70,13 @@ }).toArray(); | ||
| var chosenType = types[type]; | ||
| var $ = cheerio.load(src); | ||
| const chosenType = types[type]; | ||
| const $ = cheerio.load(src); | ||
| return Array.prototype.map.call($(chosenType.selector), function(el) { | ||
| var $el = $(el); | ||
| return Array.prototype.map.call($(chosenType.selector), el => { | ||
| const $el = $(el); | ||
| return { | ||
| $el: $el, | ||
| $el, | ||
| value: $el.attr(chosenType.attribute) | ||
| } | ||
| }; | ||
| }); | ||
| }; |
+7
-7
| { | ||
| "name": "oust", | ||
| "version": "0.4.0", | ||
| "author": "Addy Osmani <addyosmani@gmail.com> (http://addyosmani.com)", | ||
| "version": "0.5.0", | ||
| "author": "Addy Osmani <addyosmani@gmail.com> (https://addyosmani.com)", | ||
| "license": "Apache-2.0", | ||
@@ -9,3 +9,3 @@ "description": "Extract URLs to stylesheets, scripts, links, images or HTML imports from HTML", | ||
| "type": "git", | ||
| "url": "https://github.com/addyosmani/oust.git" | ||
| "url": "git+https://github.com/addyosmani/oust.git" | ||
| }, | ||
@@ -28,7 +28,7 @@ "bugs": { | ||
| "dependencies": { | ||
| "cheerio": "^0.19.0", | ||
| "minimist": "^1.1.0" | ||
| "cheerio": "^0.22.0", | ||
| "minimist": "^1.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "mocha": "*" | ||
| "mocha": "^5.2.0" | ||
| }, | ||
@@ -43,4 +43,4 @@ "keywords": [ | ||
| "engines": { | ||
| "node": ">=0.10.0" | ||
| "node": ">=6" | ||
| } | ||
| } |
+3
-2
@@ -1,2 +0,2 @@ | ||
| # oust [](https://travis-ci.org/addyosmani/oust) | ||
| # oust [](https://travis-ci.org/addyosmani/oust) [](https://david-dm.org/addyosmani/oust) [](https://david-dm.org/addyosmani/oust?type=dev) | ||
@@ -62,3 +62,4 @@ > Extract URLs to stylesheets, scripts, links, images or HTML imports from HTML | ||
| #### Extract cheerio elements alongside the value | ||
| Usefull for post processing/filtering as you get an array of matched elements | ||
| Usefull for post processing/filtering as you get an array of matched elements | ||
| with cheerio convenience syntax (e.g. `$el.attr()`) | ||
@@ -65,0 +66,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
18022
4.42%133
0.76%102
-0.97%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated