mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Update update-notifier typings
This commit is contained in:
66
update-notifier/index.d.ts
vendored
66
update-notifier/index.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user