forked from npm/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix: remove test coverage map (npm#4862)"
This reverts commit 48d2db6.
- Loading branch information
1 parent
48d2db6
commit f25e687
Showing
19 changed files
with
861 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = filter | ||
function filter (data, include, exclude, opts) { | ||
return typeof data === 'object' && | ||
filterWords(data, include, exclude, opts) | ||
} | ||
|
||
function getWords (data, opts) { | ||
return [data.name] | ||
.concat((opts && opts.description) ? data.description : []) | ||
.concat((data.maintainers || []).map(m => `=${m.name}`)) | ||
.concat(data.versions && data.versions.length && data.url && ('<' + data.url + '>')) | ||
.concat(data.keywords || []) | ||
.map(f => f && f.trim && f.trim()) | ||
.filter(f => f) | ||
.join(' ') | ||
.toLowerCase() | ||
} | ||
|
||
function filterWords (data, include, exclude, opts) { | ||
var words = getWords(data, opts) | ||
for (var i = 0, l = include.length; i < l; i++) { | ||
if (!match(words, include[i])) { | ||
return false | ||
} | ||
} | ||
|
||
for (i = 0, l = exclude.length; i < l; i++) { | ||
if (match(words, exclude[i])) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
function match (words, pattern) { | ||
if (pattern.charAt(0) === '/') { | ||
pattern = pattern.replace(/\/$/, '') | ||
pattern = new RegExp(pattern.slice(1)) | ||
return words.match(pattern) | ||
} | ||
return words.indexOf(pattern) !== -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const fs = require('fs') | ||
const util = require('util') | ||
|
||
const stat = util.promisify(fs.stat) | ||
|
||
const fileExists = (file) => stat(file) | ||
.then((stat) => stat.isFile()) | ||
.catch(() => false) | ||
|
||
module.exports = fileExists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { resolve } = require('path') | ||
const readJson = require('read-package-json-fast') | ||
async function readLocalPackageName (prefix) { | ||
const filepath = resolve(prefix, 'package.json') | ||
const json = await readJson(filepath) | ||
return json.name | ||
} | ||
|
||
module.exports = readLocalPackageName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.