From 9ea181c4ecf146a7e3df8b2b32873874d404d4b5 Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Mon, 22 Aug 2022 12:49:17 -0700 Subject: [PATCH] Call arborist.loadActual with forceActual: true See https://github.com/jslicense/licensee.js/issues/64#issuecomment-1212651518 --- index.js | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index e5c6b9b..d65cb15 100644 --- a/index.js +++ b/index.js @@ -3,12 +3,10 @@ module.exports = licensee 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') @@ -35,29 +33,18 @@ function licensee (configuration, path, callback) { ) { callback(new Error('No licenses or packages allowed.')) } else { - // 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, [])) - }) - } - ) + var arborist = new Arborist({ path }) + arborist.loadActual({ forceActual: true }) + .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, [])) + }) } }