From bf81681f9a96500565e6364a10a7d4c7caf05c01 Mon Sep 17 00:00:00 2001 From: thalles Date: Fri, 30 Jul 2021 09:33:28 -0300 Subject: [PATCH 1/3] try fix Signed-off-by: thalles --- licence.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/licence.js b/licence.js index 275236f..c407cbc 100644 --- a/licence.js +++ b/licence.js @@ -19,7 +19,7 @@ const github = require('@actions/github') const fs = require("fs"); const util = require("util"); const chalk = require("chalk"); -async function hasCorrectCopyrightDate(copyrightFile, file, startDateLicense) { +function hasCorrectCopyrightDate(copyrightFile, file, startDateLicense) { let requiredDate = '' console.log(file.year) if (file.status === 'modified'){ @@ -51,7 +51,7 @@ async function checkLicenseFile(file, config, fd) { let buffer = new Buffer(8000) return await new Promise( (resolve, reject) => { - fs.read(fd, buffer, 0, 8000, 0, async (err) => { + fs.read(fd, buffer, 0, 8000, 0, (err) => { if (err) { console.error(`Error reading file ${err}`) } @@ -65,7 +65,7 @@ async function checkLicenseFile(file, config, fd) { reject(file.name) } else { - const correctDate = await hasCorrectCopyrightDate(copyrightFile, file, config.startDateLicense) + const correctDate = hasCorrectCopyrightDate(copyrightFile, file, config.startDateLicense) if (correctDate) { console.log('File ' + chalk.yellow(file.name+": ") + chalk.green('ok!')) resolve() @@ -110,9 +110,7 @@ async function getCreationYear(file, config) { const commitsDates = response.data.map( data => new Date(data.commit.author.date) ) - console.log(commitsDates) const creationDate = Math.min.apply(null, commitsDates) - console.log(creationDate) return new Date(creationDate).getFullYear() } @@ -149,13 +147,14 @@ const checkLicense = async (fileNames, config) => { } ) const filesFiltered = removeIgnoredFiles(filesPr, fileNames) - await filesFiltered.map( - (file) => { + await Promise.all(filesFiltered.map( + async (file) => { return { ...file, - year : getCreationYear(file, config) + year : getCreationYear(file, config) } - }) + })) + console.log(filesFiltered) return await checkFilesLicense(filesFiltered, config) } From 6e577774902ea88fe3e4b577edfa1af9aade918a Mon Sep 17 00:00:00 2001 From: thalles Date: Fri, 30 Jul 2021 09:35:00 -0300 Subject: [PATCH 2/3] try fix Signed-off-by: thalles --- licence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/licence.js b/licence.js index c407cbc..036c766 100644 --- a/licence.js +++ b/licence.js @@ -148,7 +148,7 @@ const checkLicense = async (fileNames, config) => { ) const filesFiltered = removeIgnoredFiles(filesPr, fileNames) await Promise.all(filesFiltered.map( - async (file) => { + (file) => { return { ...file, year : getCreationYear(file, config) From b7e019ae4944088f48ff92a76d09b7d6f8e65429 Mon Sep 17 00:00:00 2001 From: thalles Date: Fri, 30 Jul 2021 09:37:04 -0300 Subject: [PATCH 3/3] try fix Signed-off-by: thalles --- licence.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/licence.js b/licence.js index 036c766..96ea626 100644 --- a/licence.js +++ b/licence.js @@ -147,15 +147,15 @@ const checkLicense = async (fileNames, config) => { } ) const filesFiltered = removeIgnoredFiles(filesPr, fileNames) - await Promise.all(filesFiltered.map( + const filesWithYear = await Promise.all(filesFiltered.map( (file) => { return { ...file, year : getCreationYear(file, config) } })) - console.log(filesFiltered) - return await checkFilesLicense(filesFiltered, config) + console.log(filesWithYear) + return await checkFilesLicense(filesWithYear, config) }