@snyk/code-client
Advanced tools
Comparing version 4.18.4 to 4.18.5
@@ -152,7 +152,10 @@ "use strict"; | ||
if (languages) { | ||
const supportedFiles = {}; | ||
supportedFiles.configFiles = supportedFilesFromApi.configFiles; | ||
supportedFiles.extensions = languages; | ||
const supportedFiles = { | ||
configFiles: supportedFilesFromApi.configFiles, | ||
extensions: languages, | ||
}; | ||
//For verification only | ||
supportedFiles.extensions = supportedFiles.extensions.filter(langExtension => supportedFilesFromApi.extensions.includes(langExtension)); | ||
// Make sure we compare file extensions between results from `registry` and `deeproxy` without case sensitivity to avoid missing some of supported extensions. | ||
const userSupportedExtensions = supportedFilesFromApi.extensions.map(e => e.toLowerCase()); | ||
supportedFiles.extensions = supportedFiles.extensions.filter(langExtension => userSupportedExtensions.includes(langExtension.toLowerCase())); | ||
emitter_1.emitter.supportedFilesLoaded(supportedFiles); | ||
@@ -159,0 +162,0 @@ return supportedFiles; |
@@ -147,3 +147,3 @@ "use strict"; | ||
return [ | ||
...supportedFiles.extensions.map(e => `*${e}`), | ||
...supportedFiles.extensions.map(e => `${generateAllCaseGlobPattern(e)}`), | ||
...supportedFiles.configFiles.filter(e => !constants_1.EXCLUDED_NAMES.includes(e)), | ||
@@ -153,2 +153,28 @@ ]; | ||
exports.getGlobPatterns = getGlobPatterns; | ||
// Generates glob patterns for case-insensitive file extension matching. | ||
// E.g. *.[jJ][sS] for matching .js files without case-sensitivity. | ||
function generateAllCaseGlobPattern(fileExtension) { | ||
const chars = Array.from(fileExtension); | ||
if (!chars.length) { | ||
console.log('Invalid file extension pattern: file extension is empty.'); | ||
return ''; | ||
} | ||
if (chars[0] != '.') { | ||
console.log("Invalid file extension pattern: missing '.' in the beginning of the file extension. Some files may not be included in the analysis."); | ||
return ''; | ||
} | ||
const caseInsensitivePatterns = chars.reduce((pattern, extensionChar, i) => { | ||
if (i == 0) { | ||
// first char should always be '.', no need to generate multiple cases for file extension character | ||
return ['*.']; | ||
} | ||
if (extensionChar.toLowerCase() == extensionChar.toUpperCase()) { | ||
// Char doesn't have case variant, return as-is. | ||
return pattern.concat(extensionChar); | ||
} | ||
const globCharPattern = `[${extensionChar.toLowerCase()}${extensionChar.toUpperCase()}]`; | ||
return pattern.concat(globCharPattern); | ||
}, []); | ||
return caseInsensitivePatterns.join(''); | ||
} | ||
async function collectIgnoreRules(dirs, symlinksEnabled = false, fileIgnores = constants_1.IGNORES_DEFAULT) { | ||
@@ -155,0 +181,0 @@ const tasks = dirs.map(async (folder) => { |
@@ -93,3 +93,3 @@ { | ||
}, | ||
"version": "4.18.4" | ||
"version": "4.18.5" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163703
2283