Mercurial > hg > thermostat-ng > web-client
changeset 150:9d4f0f049abe
Check top level directory for malformed licenses
Reviewed-by: aazores
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024297.html
author | Christopher Koehler <chkoehle@redhat.com> |
---|---|
date | Tue, 08 Aug 2017 14:47:19 -0400 |
parents | 23d561f227fd |
children | 47c4b229c02e |
files | license-check/license-check.js license-check/perform-license-check.js |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/license-check/license-check.js Fri Aug 04 09:47:24 2017 -0400 +++ b/license-check/license-check.js Tue Aug 08 14:47:19 2017 -0400 @@ -28,7 +28,7 @@ const fs = require('fs'); const glob = require('glob'); -const FILE_GLOB = '**/*.js'; +const RECURSIVE_FILE_GLOB = '**/*.js'; const NO_SUCH_YEAR_INDEX = -1; const YEAR_LINE_REGEX = /\* .+2\d{3}-2\d{3}.+/; @@ -163,9 +163,8 @@ * for a bad file path argument to cause it to exit early and set the error * field with a reason. */ -function walkDirectoryAndCheckLicenses (directoryRootPath, licenseData) { - let fileGlob = directoryRootPath + FILE_GLOB; - let files = glob.sync(fileGlob); +function walkDirectoryAndCheckLicenses (directoryRootPath, licenseData, fileGlob = RECURSIVE_FILE_GLOB) { + let files = glob.sync(directoryRootPath + fileGlob); let returnResult = { improperLicensePaths: [], error: null,
--- a/license-check/perform-license-check.js Fri Aug 04 09:47:24 2017 -0400 +++ b/license-check/perform-license-check.js Tue Aug 08 14:47:19 2017 -0400 @@ -38,6 +38,7 @@ exitWithErrorMessage(licenseData.error); } +// Check specific files only. ['integration-test/integration-test.config.js', 'integration-test/test-env.js'].forEach((filePath) => { let fileCheckResult = licenseChecker.checkFileForLicense(filePath, licenseData); if (!fileCheckResult.success) { @@ -45,6 +46,15 @@ } }); +// Check specific directories that we do not want to recurse to any children on. +['./'].forEach((folderPath) => { + let checkResult = licenseChecker.walkDirectoryAndCheckLicenses(folderPath, licenseData, '*.js'); + if (!checkResult.success) { + exitWithErrorMessage(checkResult.error); + } +}); + +// Check all files in these folders and recursively walk all children. ['license-check/', 'src/app/'].forEach((folderPath) => { let checkResult = licenseChecker.walkDirectoryAndCheckLicenses(folderPath, licenseData); if (!checkResult.success) {