Skip to content

Commit

Permalink
Merge pull request #20 from thalleslmF/pr-21
Browse files Browse the repository at this point in the history
Pr 21
  • Loading branch information
thalleslmF authored Jul 29, 2021
2 parents 61c638f + 51d6607 commit b43e411
Show file tree
Hide file tree
Showing 38 changed files with 4,113 additions and 10 deletions.
7 changes: 4 additions & 3 deletions licence.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const core = require('@actions/core')
const github = require('@actions/github')
const fs = require("fs");
const util = require("util");

const chalk = require('chalk')
function hasCorrectCopyrightDate(copyrightFile, status, startDateLicense) {
let requiredDate = ''
if (status === 'modified'){
Expand Down Expand Up @@ -57,16 +57,17 @@ async function checkLicenseFile(file, config, fd) {
)

if (!allCopyrightIncluded) {
console.error(`File ${file.name} :No copyright header!`)
console.log('File ' + chalk.yellow(file.name) + chalk.red(': No copyright header!'))
reject(file.name)
} else {

const correctDate = hasCorrectCopyrightDate(copyrightFile, file.status, config.startDateLicense)
if (correctDate) {
console.log('File ' + chalk.yellow(file.name) + chalk.green(': ok!'))
console.log(`File ${file.name} :ok!`)
resolve()
} else {
console.error(`fix file: ${file.name} copyright date!`)
console.log(`file ${file.name}: Fix copyright date!`)
reject(file.name)
}
}
Expand Down
18 changes: 11 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

const { checkLicense } = require("./licence");
const util = require("util");
const core = require('@actions/core')
const util = require("util")
const chalk = require('chalk')
fs = require('fs');
glob = require('glob')
let file = "config.json"
Expand All @@ -10,11 +13,12 @@ let ignore = dataObject.ignore
let startDateLicense = dataObject.startDateLicense
glob(
"**/*.*",{cwd: process.cwd(), ignore }, async (err,fileNames) => {
const errors = await checkLicense(fileNames, { copyrightContent: copyrightContent, startDateLicense: startDateLicense })
if(errors) {
console.log(errors.title)
console.log(errors.details)
process.exit()
const error = await checkLicense(fileNames, { copyrightContent: copyrightContent, startDateLicense: startDateLicense })
if(error) {
console.log(chalk.red(error.title))
console.log(chalk.red(error.message))
core.setFailed('Action failed');
}
}
)
)
console.log('should fail')
Loading

0 comments on commit b43e411

Please sign in to comment.