Skip to content

Commit 1f6a204

Browse files
committed
Use npm lockfile v2 for dependency-check compatibility
1 parent e5eae08 commit 1f6a204

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

test-local.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
4+
const analyze = require('./index.js')
5+
6+
async function main() {
7+
// Note: Replace with a valid NCM API token
8+
// Set via environment variable: NCM_TOKEN=your-token node test-local.js
9+
const token = process.env.NCM_TOKEN || 'accounts token'
10+
11+
const data = await analyze({
12+
dir: __dirname,
13+
token: token,
14+
onPkgs: pkgs => console.log(`Analyzing ${pkgs.size} modules...`)
15+
})
16+
17+
for (const pkg of data) {
18+
console.log(`${pkg.name}@${pkg.version}`)
19+
20+
// Display scores if available
21+
if (pkg.scores && pkg.scores.length > 0) {
22+
console.log(' Scores:')
23+
for (const score of pkg.scores) {
24+
const status = score.pass ? '✓' : '✗'
25+
console.log(` ${status} ${score.title} (${score.severity})`)
26+
}
27+
}
28+
29+
// Display paths if available
30+
if (pkg.paths && pkg.paths.length > 0) {
31+
console.log(' Dependency paths:')
32+
for (const path of pkg.paths) {
33+
console.log(` ${path.map(p => `${p.data.name}@${p.data.version}`).join(' > ')}`)
34+
}
35+
}
36+
37+
console.log('')
38+
}
39+
}
40+
41+
main().catch(err => {
42+
console.error('Error:', err)
43+
process.exit(1)
44+
})

0 commit comments

Comments
 (0)