Skip to content

Commit

Permalink
Clobber .package-lock.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
kemitchell committed Jun 2, 2022
1 parent cf535d2 commit 6e763fe
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 203 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.package-lock.json
39 changes: 26 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module.exports = licensee

var blueOakList = require('@blueoak/list')
var Arborist = require('@npmcli/arborist')
var blueOakList = require('@blueoak/list')
var correctLicenseMetadata = require('correct-license-metadata')
var fs = require('fs')
var has = require('has')
var npmLicenseCorrections = require('npm-license-corrections')
var osi = require('spdx-osi')
var parse = require('spdx-expression-parse')
var joinPath = require('path').join
var satisfies = require('semver').satisfies
var spdxAllowed = require('spdx-whitelisted')

Expand All @@ -33,18 +35,29 @@ function licensee (configuration, path, callback) {
) {
callback(new Error('No licenses or packages allowed.'))
} else {
var arborist = new Arborist({ path })
arborist.loadActual()
.catch(function (error) {
return callback(error)
})
.then(function (tree) {
var children = Array.from(tree.children.values())
if (configuration.filterPackages) {
children = configuration.filterPackages(children)
}
callback(null, findIssues(configuration, children, []))
})
// Delete node_modules/.package-lock.json, Arborist/npm's
// on-disk cache of the resolved package tree, if
// present. When this is present, it may or may
// not include license metadata for packages. See
// https://github.com/jslicense/licensee.js/issues/64#issuecomment-1145256328=
fs.rm(
joinPath(path, 'node_modules', '.package-lock.json'),
{ force: true },
function (/* ignore errors */) {
var arborist = new Arborist({ path })
arborist.loadActual()
.catch(function (error) {
return callback(error)
})
.then(function (tree) {
var children = Array.from(tree.children.values())
if (configuration.filterPackages) {
children = configuration.filterPackages(children)
}
callback(null, findIssues(configuration, children, []))
})
}
)
}
}

Expand Down
12 changes: 0 additions & 12 deletions tests/allowed/node_modules/.package-lock.json

This file was deleted.

17 changes: 0 additions & 17 deletions tests/apache-2.0-mit-allowed/node_modules/.package-lock.json

This file was deleted.

17 changes: 0 additions & 17 deletions tests/apache-2.0-mit-allowed/package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/blue-oak-fail/node_modules/.package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/blue-oak-gold-mit/node_modules/.package-lock.json

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions tests/mit-not-allowed/node_modules/.package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/no-allowlist/node_modules/.package-lock.json

This file was deleted.

29 changes: 0 additions & 29 deletions tests/optimist-without-corrections/node_modules/.package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions tests/out-of-allowed-range/node_modules/.package-lock.json

This file was deleted.

4 changes: 2 additions & 2 deletions tests/out-of-allowed-range/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ tap.equal(
'mit-licensed@1.0.0',
' NOT APPROVED',
' Terms: MIT',
' Repository: git+https://github.com/jslicense/mit-licensed.js.git',
' Homepage: https://github.com/jslicense/mit-licensed.js#readme',
' Repository: jslicense/mit-licensed.js',
' Homepage: None listed',
' Author: Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com/)',
' Contributors: None listed'
].join('\n')
Expand Down
18 changes: 0 additions & 18 deletions tests/production-only/node_modules/.package-lock.json

This file was deleted.

20 changes: 0 additions & 20 deletions tests/unlicensed-subdependency/node_modules/.package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions tests/unlicensed-subdependency/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ tap.equal(
'mit-licensed-depends-on-not-licensed@1.0.1',
' NOT APPROVED',
' Terms: MIT',
' Repository: git+https://github.com/jslicense/mit-licensed-depends-on-not-licensed.js.git',
' Homepage: https://github.com/jslicense/mit-licensed-depends-on-not-licensed.js#readme',
' Repository: jslicense/mit-licensed-depends-on-not-licensed.js',
' Homepage: None listed',
' Author: Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com/)',
' Contributors: None listed',
'',
'not-licensed@1.0.0',
' NOT APPROVED',
' Terms: Invalid license metadata',
' Repository: git+https://github.com/jslicense/not-licensed.js.git',
' Homepage: https://github.com/jslicense/not-licensed.js#readme',
' Repository: jslicense/not-licensed.js',
' Homepage: None listed',
' Author: Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com/)',
' Contributors: None listed'
].join('\n')
Expand Down

0 comments on commit 6e763fe

Please # to comment.