Add typings for legal-eagle (#22722)

This commit is contained in:
Jed Fox
2018-01-07 03:20:09 -05:00
committed by Mohamed Hegazy
parent d5a34a4bd0
commit bb43bdb9d1
4 changed files with 96 additions and 0 deletions

28
types/legal-eagle/index.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
// Type definitions for legal-eagle 0.15
// Project: https://github.com/atom/legal-eagle
// Definitions by: Jed Fox <https://github.com/j-f1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function legalEagle(
options: legalEagle.Options,
cb: (err: Error | null, licenseSummary: legalEagle.LicenseLookup) => void
): void;
declare namespace legalEagle {
interface Options {
path: string;
overrides?: LicenseLookup;
omitPermissive?: boolean;
}
interface LicenseLookup {
[id: string]: Entry;
}
interface Entry {
license: string;
source: string;
repository: string;
sourceText: string;
}
}
export = legalEagle;

View File

@@ -0,0 +1,44 @@
/// <reference types="node" />
import legalEagle = require('legal-eagle');
// from the package's README
legalEagle({path: process.cwd()}, (err, summary) => {
if (err != null) {
console.error(err);
return;
}
console.log(summary);
});
// from GitHub desktop
declare var appRoot: string;
legalEagle(
{
path: appRoot,
overrides: {
'foo@1.2.3': {
repository: 'git+ssh://git@github.com/foo/bar',
license: '...',
source: '...',
sourceText: '...',
}
},
omitPermissive: true
}, (err, summary) => {
if (err) {
console.error(err);
return;
}
if (Object.keys(summary).length > 0) {
let licensesMessage = '';
for (const key in summary) {
const license = summary[key];
licensesMessage += `${key} (${license.repository}): ${license.license}\n`;
}
throw new Error(licensesMessage);
}
}
);

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"legal-eagle-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }