diff --git a/lib/index.js b/lib/index.js index b6d5148..1ff8060 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,6 +6,9 @@ http://yuilibrary.com/license/ const LICENSE_TITLE_UNKNOWN = 'UNKNOWN'; const LICENSE_TITLE_UNLICENSED = 'UNLICENSED'; +const INITIAL_MODULE_INFO = { + licenses: LICENSE_TITLE_UNKNOWN, +}; const chalk = require('chalk'); const debug = require('debug'); @@ -32,15 +35,16 @@ debugLog.log = console.log.bind(console); // This function calls itself recursively. On the first iteration, it collects the data of the main program, during the // second iteration, it collects the data from all direct dependencies, then it collects their dependencies and so on. const recursivelyCollectAllDependencies = (options) => { - const moduleInfo = { licenses: LICENSE_TITLE_UNKNOWN }; const { color: colorize, deps: currentExtendedPackageJson, unknown } = options; + const moduleInfo = { ...INITIAL_MODULE_INFO }; const currentPackageNameAndVersion = `${currentExtendedPackageJson.name}@${currentExtendedPackageJson.version}`; + + let { data } = options; let licenseFilesInCurrentModuleDirectory = []; let licenseData; let licenseFile; let noticeFiles = []; let readmeFile; - let { data } = options; let clarification = options.clarifications?.[currentPackageNameAndVersion]; let passedClarificationCheck = clarification?.checksum ? false : true;