Skip to content

Commit

Permalink
refactor: Transform snake case into camel case
Browse files Browse the repository at this point in the history
Also define a constant as const instead of as a let
  • Loading branch information
RSeidelsohn committed Apr 10, 2023
1 parent 129b6aa commit f4788b6
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const recursivelyCollectAllDependencies = (options) => {
let readmeFile;
let { data } = options;
let clarification = options.clarifications?.[currentPackageNameAndVersion];
let passed_clarification_check = clarification?.checksum ? false : true;
let passedClarificationCheck = clarification?.checksum ? false : true;

if (json.private) {
moduleInfo.private = true;
Expand Down Expand Up @@ -122,15 +122,15 @@ const recursivelyCollectAllDependencies = (options) => {
moduleInfo.dependencyPath = json.path;
}

let module_path = getFirstNotUndefinedOrUndefined(clarification?.path, json?.path);
if (mustInclude('path') && typeof module_path === 'string') {
moduleInfo.path = module_path;
const modulePath = getFirstNotUndefinedOrUndefined(clarification?.path, json?.path);
if (mustInclude('path') && typeof modulePath === 'string') {
moduleInfo.path = modulePath;
}

licenseData = getFirstNotUndefinedOrUndefined(clarification?.licenses, json.license, json.licenses);

if (module_path && (!json.readme || json.readme.toLowerCase().indexOf('no readme data found') > -1)) {
readmeFile = path.join(module_path, 'README.md');
if (modulePath && (!json.readme || json.readme.toLowerCase().indexOf('no readme data found') > -1)) {
readmeFile = path.join(modulePath, 'README.md');
/*istanbul ignore if*/
if (fs.existsSync(readmeFile)) {
json.readme = fs.readFileSync(readmeFile, 'utf8').toString();
Expand Down Expand Up @@ -170,8 +170,8 @@ const recursivelyCollectAllDependencies = (options) => {
/*istanbul ignore else*/
if (clarification?.licenseFile) {
licenseFilesInCurrentModuleDirectory = [clarification.licenseFile];
} else if (fs.existsSync(module_path)) {
const filesInModuleDirectory = fs.readdirSync(module_path);
} else if (fs.existsSync(modulePath)) {
const filesInModuleDirectory = fs.readdirSync(modulePath);
licenseFilesInCurrentModuleDirectory = licenseFiles(filesInModuleDirectory);

noticeFiles = filesInModuleDirectory.filter((filename) => {
Expand All @@ -183,7 +183,7 @@ const recursivelyCollectAllDependencies = (options) => {
}

licenseFilesInCurrentModuleDirectory.forEach(function findBetterLicenseData(filename, index) {
licenseFile = path.join(module_path, filename);
licenseFile = path.join(modulePath, filename);
// Checking that the file is in fact a normal file and not a directory for example.
/*istanbul ignore else*/
if (fs.lstatSync(licenseFile).isFile()) {
Expand All @@ -204,7 +204,7 @@ const recursivelyCollectAllDependencies = (options) => {
if (index === 0) {
// Treat the file with the highest precedence as licenseFile

if (clarification !== undefined && !passed_clarification_check) {
if (clarification !== undefined && !passedClarificationCheck) {
/*istanbul ignore else*/
if (!currentLicenceFilesContent) {
currentLicenceFilesContent = fs.readFileSync(licenseFile, { encoding: 'utf8' });
Expand All @@ -218,7 +218,7 @@ const recursivelyCollectAllDependencies = (options) => {
);
process.exit(1);
} else {
passed_clarification_check = true;
passedClarificationCheck = true;
}
}

Expand Down Expand Up @@ -302,6 +302,7 @@ const recursivelyCollectAllDependencies = (options) => {
});

if (!passed_clarification_check) {
if (!passedClarificationCheck) {
console.error('All clarifications must come with a checksum');
process.exit(1);
}
Expand Down

0 comments on commit f4788b6

Please sign in to comment.