Skip to content

Commit

Permalink
🐛 fix no-unpublished-bin false positive (fixes #115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jan 4, 2019
1 parent 0225b02 commit e2fc482
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/util/get-npmignore.js
Expand Up @@ -84,18 +84,17 @@ function parseWhiteList(files) {
}

const ig = ignore()
ig.add("*")

for (const file of files) {
if (typeof file === "string" && file) {
const prefix = file.startsWith("!") ? "" : "!"
const prefix = file.startsWith("!") ? "!" : ""
const body = file.replace(SLASH_AT_BEGIN_AND_END, "")
ig.add(`${prefix}/${body}`)
ig.add(`${prefix}/${body}/**`)
}
}

return not(ig.createFilter())
return ig.createFilter()
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/no-unpublished-bin/issue115/package.json
@@ -0,0 +1,7 @@
{
"private": true,
"name": "test",
"version": "1.0.0",
"bin": {"a": "lib/a.js"},
"files": ["lib/a.js"]
}
4 changes: 4 additions & 0 deletions tests/lib/rules/no-unpublished-bin.js
Expand Up @@ -63,6 +63,10 @@ new RuleTester().run("no-unpublished-bin", rule, {
code: "'multi-npmignore/lib/a.js'",
filename: fixture("multi-npmignore/lib/a.js"),
},
{
code: "'issue115/lib/a.js'",
filename: fixture("issue115/lib/a.js"),
},

// empty name
"'stdin'",
Expand Down

0 comments on commit e2fc482

Please sign in to comment.