Comparing version 0.4.0 to 0.5.0
22
cli.js
#!/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); |
31
index.js
@@ -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) | ||
} | ||
}; | ||
}); | ||
}; |
{ | ||
"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" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# oust [![Build Status](https://travis-ci.org/addyosmani/oust.svg?branch=master)](https://travis-ci.org/addyosmani/oust) | ||
# oust [![Build Status](https://img.shields.io/travis/addyosmani/oust/master.svg)](https://travis-ci.org/addyosmani/oust) [![dependencies Status](https://img.shields.io/david/addyosmani/oust.svg)](https://david-dm.org/addyosmani/oust) [![devDependencies Status](https://img.shields.io/david/dev/addyosmani/oust.svg)](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 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18022
133
102
+ Addedcheerio@0.22.0(transitive)
+ Addedcss-select@1.2.0(transitive)
+ Addedcss-what@2.1.3(transitive)
+ Addeddomhandler@2.4.2(transitive)
+ Addedhtmlparser2@3.10.1(transitive)
+ Addedlodash.assignin@4.2.0(transitive)
+ Addedlodash.bind@4.2.1(transitive)
+ Addedlodash.defaults@4.2.0(transitive)
+ Addedlodash.filter@4.6.0(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.foreach@4.5.0(transitive)
+ Addedlodash.map@4.6.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedlodash.pick@4.4.0(transitive)
+ Addedlodash.reduce@4.6.0(transitive)
+ Addedlodash.reject@4.6.0(transitive)
+ Addedlodash.some@4.6.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedcheerio@0.19.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcss-select@1.0.0(transitive)
- Removedcss-what@1.0.0(transitive)
- Removeddomhandler@2.3.0(transitive)
- Removeddomutils@1.4.3(transitive)
- Removedentities@1.0.0(transitive)
- Removedhtmlparser2@3.8.3(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash@3.10.1(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedstring_decoder@0.10.31(transitive)
Updatedcheerio@^0.22.0
Updatedminimist@^1.2.0