Skip to content

Commit 665b0d6

Browse files
committed
Fix detection of native and ignoreNative option
1 parent 0317493 commit 665b0d6

6 files changed

Lines changed: 149 additions & 122 deletions

File tree

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
required: false
66
default: ""
77
description: "Packages to ignore, a JSON object or array"
8+
ignoreNative:
9+
required: false
10+
default: false
11+
description: "Ignore implicit build step for node-gyp bindings"
812
runs:
913
using: "node24"
1014
main: "dist/index.js"

dist/index.js

Lines changed: 118 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "npm-no-scripts",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Verify NPM dependencies don't have lifecycle scripts",
55
"homepage": "https://github.com/cryptool-org/npm-no-scripts#readme",
66
"bugs": {

src/app.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { depth as traverse } from "treeverse"
44

55
import { analyze } from "./analyze"
66
import { shouldIgnoreFinding, shouldIgnorePackage } from "./ignore"
7-
import { getIgnoreList } from "./input"
7+
import { getIgnoreList, getIgnoreNative } from "./input"
88

99
async function run() {
1010
try {
1111
// Get list of packages to ignore from the input
1212
const ignoreList = getIgnoreList()
13+
const shouldIgnoreNative = getIgnoreNative()
1314

1415
// Walk the node_modules/ folder to build a list of all installed dependencies
1516
core.debug("Load installed packages in node_modules/")
@@ -31,6 +32,7 @@ async function run() {
3132
// Aggregate all findings (and respect ignored packages)
3233
const ignored = new Set()
3334
const errors = []
35+
3436
for (const [name, info] of results.entries()) {
3537
if (shouldIgnorePackage(ignoreList, info.node.target)) {
3638
ignored.add(name)
@@ -41,6 +43,11 @@ async function run() {
4143
ignored.add(name)
4244
continue
4345
}
46+
if (f.type === "NATIVE_BINDINGS" && shouldIgnoreNative) {
47+
ignored.add(name)
48+
continue
49+
}
50+
4451
const version = info.node.target.version
4552
if (f.type === "NATIVE_BINDINGS") {
4653
errors.push(

src/input.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ function validateIgnoreOptions(item, opts) {
6060

6161
if (native === true || native === "true" || native === 1) {
6262
options.native = true
63-
} else if (native === false || native === "false" || native === 0) {
63+
} else if (
64+
native === null ||
65+
native === undefined ||
66+
native === false ||
67+
native === "false" ||
68+
native === 0
69+
) {
6470
// these will also be false, as is the default
6571
} else if (typeof native !== "boolean") {
6672
core.warning(`Invalid format for '${item}.native': Must be 'boolean'`)
@@ -102,3 +108,12 @@ export function getIgnoreList() {
102108

103109
return ignores
104110
}
111+
112+
export function getIgnoreNative() {
113+
try {
114+
return core.getBooleanInput("ignoreNative", { required: false })
115+
} catch (err) {
116+
core.warning(err)
117+
return false
118+
}
119+
}

0 commit comments

Comments
 (0)