fix(core): update

This commit is contained in:
2021-05-17 15:45:46 +00:00
parent 83a9cabab8
commit 4b5b2e7ca5
8 changed files with 10536 additions and 1059 deletions

View File

@ -0,0 +1,14 @@
import { IModuleLicenseResult } from "./interfaces";
export class CheckResult {
passingModules: IModuleLicenseResult[] = [];
failingModules: IModuleLicenseResult[] = [];
public addPassing(moduleResultArg: IModuleLicenseResult) {
this.passingModules.push(moduleResultArg);
}
public addFailing(moduleResultArg: IModuleLicenseResult) {
this.failingModules.push(moduleResultArg);
}
}

View File

@ -1,27 +1,7 @@
import * as plugins from '../legal.plugins';
import * as licenseChecker from 'license-checker';
export interface IModuleLicenseResult {
moduleName: string;
license: string;
repository: string;
publisher: string;
email: string;
path: string;
licenseFile: string;
}
export class CheckResult {
passingModules: IModuleLicenseResult[] = [];
failingModules: IModuleLicenseResult[] = [];
addPassing(moduleResultArg: IModuleLicenseResult) {
this.passingModules.push(moduleResultArg);
}
addFailing(moduleResultArg: IModuleLicenseResult) {
this.failingModules.push(moduleResultArg);
}
}
import * as interfaces from './interfaces';
import { CheckResult } from './classes.checkresult';
export class LicenseChecker {
async excludeLicenseWithinPath(pathArg: string, licenseArrayArg: string[]) {
@ -52,8 +32,8 @@ export class LicenseChecker {
async createPlainResultArray(pathArg: string) {
const licenseJson = await this.getJsonForPath(pathArg);
const resultArray: IModuleLicenseResult[] = [];
for (let moduleKey in licenseJson) {
const resultArray: interfaces.IModuleLicenseResult[] = [];
for (const moduleKey of Object.keys(licenseJson)) {
const refObject = licenseJson[moduleKey];
resultArray.push({
moduleName: moduleKey,
@ -69,12 +49,12 @@ export class LicenseChecker {
}
private async getJsonForPath(checkPathArg) {
let done = plugins.smartpromise.defer<any>();
const done = plugins.smartpromise.defer<any>();
licenseChecker.init(
{
start: checkPathArg
},
function(err, licenseJson) {
(err, licenseJson) => {
if (err) {
done.reject(err);
} else {
@ -82,6 +62,6 @@ export class LicenseChecker {
}
}
);
return await done.promise;
return done.promise;
}
}

View File

@ -0,0 +1,9 @@
export interface IModuleLicenseResult {
moduleName: string;
license: string;
repository: string;
publisher: string;
email: string;
path: string;
licenseFile: string;
}