@erickmerchant/checkup
Advanced tools
Comparing version 11.2.0 to 11.3.0
{ | ||
"name": "@erickmerchant/checkup", | ||
"version": "11.2.0", | ||
"version": "11.3.0", | ||
"description": "Check multiple projects for various things.", | ||
@@ -23,6 +23,7 @@ "bin": { | ||
"detective-es6": "^2.0.0", | ||
"detective-postcss": "^3.0.0", | ||
"detective-postcss": "^3.0.1", | ||
"execa": "^1.0.0", | ||
"globby": "^9.1.0", | ||
"kleur": "^3.0.2", | ||
"parse5": "^5.1.0", | ||
"semver": "^5.6.0", | ||
@@ -33,3 +34,3 @@ "sergeant": "^24.1.3" | ||
"@erickmerchant/lint": "^2.0.1", | ||
"eslint": "^5.15.0", | ||
"eslint": "^5.15.1", | ||
"proxyquire": "^2.1.0", | ||
@@ -36,0 +37,0 @@ "tape": "^4.10.0" |
@@ -7,2 +7,3 @@ const fs = require('fs') | ||
const fsReadFile = promisify(fs.readFile) | ||
const parse5 = require('parse5') | ||
const detective = require('detective') | ||
@@ -13,2 +14,45 @@ const detectiveES6 = require('detective-es6') | ||
const detectiveHTML = (code) => { | ||
const traverse = (nodes) => { | ||
const results = [] | ||
for (const node of nodes) { | ||
if (node.tagName === 'link') { | ||
const rel = node.attrs.find((attr) => attr.name === 'rel') | ||
if (rel != null && rel.value === 'stylesheet') { | ||
const href = node.attrs.find((attr) => attr.name === 'href') | ||
if (href != null) results.push(href.value) | ||
} | ||
} | ||
if (node.tagName === 'style' && node.childNodes != null && node.childNodes[0] != null) { | ||
results.push(...detectivePostcss(node.childNodes[0].value)) | ||
} | ||
if (node.tagName === 'script') { | ||
const src = node.attrs.find((attr) => attr.name === 'src') | ||
const type = node.attrs.find((attr) => attr.name === 'type') | ||
if (type != null && type.value === 'module') { | ||
if (src != null) { | ||
results.push(src.value) | ||
} else if (node.childNodes != null && node.childNodes[0] != null) { | ||
results.push(...detectiveES6(node.childNodes[0].value)) | ||
} | ||
} | ||
} | ||
results.push(...traverse(node.childNodes || [])) | ||
} | ||
return results | ||
} | ||
const ast = parse5.parseFragment(code) | ||
return traverse(ast.childNodes || []) | ||
} | ||
module.exports = async (directory) => { | ||
@@ -29,3 +73,3 @@ const results = [] | ||
const files = await globby(['./**/*{js,mjs,css}'], {cwd: path.join(directory), gitignore: true}) | ||
const files = await globby(['./**/*{js,mjs,css,html}'], {cwd: path.join(directory), gitignore: true}) | ||
@@ -44,2 +88,5 @@ let deps = await Promise.all(files.map(async (file) => { | ||
return detectivePostcss(code) | ||
case '.html': | ||
return detectiveHTML(code) | ||
} | ||
@@ -46,0 +93,0 @@ })) |
20674
658
10
+ Addedparse5@^5.1.0
+ Addedparse5@5.1.1(transitive)
Updateddetective-postcss@^3.0.1