Update update-notifier typings

This commit is contained in:
Noah Chen
2016-11-16 00:11:31 -05:00
parent 0ab938b089
commit 0bc0127fea
2 changed files with 42 additions and 32 deletions

View File

@@ -3,33 +3,43 @@
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function t(settings?: t.ISettings): t.IResult;
declare namespace t {
export interface IResult {
update: IUpdateInfo;
notify(message?: string): void;
}
export interface ISettings {
callback?: (error: any, update?: IUpdateInfo) => any; // default null
packagePath?: string; // default 'package.json'
packageName?: string; // default Inferred from packageFile
packageVersion?: string; // default Inferred from packageFile
updateCheckInterval?: number; // default 1000 * 60 * 60 * 24 (1 day)
updateCheckTimeout?: number; // default 20000 (20 secs)
registryUrl?: string; // default 'http://registry.npmjs.org/%s'
}
export interface IUpdateInfo {
latest: string;
current: string;
type: string;
date: string;
name: string;
}
export interface ISettings {
pkg?: IPackage;
callback?: (update?: IUpdateInfo) => any;
packageName?: string;
packageVersion?: string;
updateCheckInterval?: number; // default 1000 * 60 * 60 * 24 (1 day)
}
export = t;
export interface IBoxenOptions {
padding: number;
margin: number;
align: string;
borderColor: string;
borderStyle: string;
}
export interface INotifyOptions {
message: string;
defer?: boolean;
boxenOpts?: IBoxenOptions;
}
export interface IPackage {
name: string;
version: string;
}
export interface IUpdateInfo {
latest: string;
current: string;
type: string;
name: string;
}
export declare class UpdateNotifier {
constructor(settings?: ISettings);
update: IUpdateInfo;
notify(message?: INotifyOptions): void;
}

View File

@@ -1,7 +1,7 @@
import updateNotifier = require('update-notifier');
import { UpdateNotifier } from "update-notifier";
var notifier = updateNotifier();
var notifier = new UpdateNotifier();
if (notifier.update) {
notifier.notify();
@@ -9,10 +9,10 @@ if (notifier.update) {
console.log(notifier.update);
var notifier = updateNotifier({
var notifier = new UpdateNotifier({
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
});
if (notifier.update) {
notifier.notify('Update available: ' + notifier.update.latest);
notifier.notify({ message: 'Update available: ' + notifier.update.latest });
}