fix(core): update
This commit is contained in:
14
ts/mod.licensechecker/classes.checkresult.ts
Normal file
14
ts/mod.licensechecker/classes.checkresult.ts
Normal 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
9
ts/mod.licensechecker/interfaces.ts
Normal file
9
ts/mod.licensechecker/interfaces.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface IModuleLicenseResult {
|
||||
moduleName: string;
|
||||
license: string;
|
||||
repository: string;
|
||||
publisher: string;
|
||||
email: string;
|
||||
path: string;
|
||||
licenseFile: string;
|
||||
}
|
Reference in New Issue
Block a user