update-notifier: Add export = declaration (#13839)

This commit is contained in:
Andy 2017-01-08 05:14:37 -08:00 committed by GitHub
parent 198918d97c
commit b259e475a5
4 changed files with 49 additions and 42 deletions

View File

@ -8,7 +8,7 @@ const path = require("path");
const symlinkedTslintPath = "../node_modules/types-publisher/node_modules/tslint"
let tslintPath = existsSync(path.join(pkg, symlinkedTslintPath)) ? symlinkedTslintPath : "../node_modules/tslint";
// An older version (e.g. abs/v0) is in a nested directory, so needs to look one more level up for tslint.
if (pkg.includes("/")) {
if (pkg.includes("/") && pkg[pkg.length - 1] !== "/") {
tslintPath = path.join("..", tslintPath);
}

View File

@ -1,47 +1,53 @@
// Type definitions for update-notifier
// Type definitions for update-notifier 1.0
// Project: https://github.com/yeoman/update-notifier
// Definitions by: vvakame <https://github.com/vvakame>, Noah Chen <https://github.com/nchen63>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ISettings {
pkg?: IPackage;
callback?: (update?: IUpdateInfo) => any;
packageName?: string;
packageVersion?: string;
updateCheckInterval?: number; // in milliseconds, default 1000 * 60 * 60 * 24 (1 day)
}
export = UpdateNotifier;
export interface IBoxenOptions {
padding: number;
margin: number;
align: string;
borderColor: string;
borderStyle: string;
}
declare function UpdateNotifier(settings?: UpdateNotifier.Settings): UpdateNotifier.UpdateNotifier;
export interface INotifyOptions {
message: string;
defer?: boolean;
boxenOpts?: IBoxenOptions;
}
declare namespace UpdateNotifier {
class UpdateNotifier {
constructor(settings?: UpdateNotifier.Settings);
export interface IPackage {
name: string;
version: string;
}
update: UpdateNotifier.UpdateInfo;
check(): void;
checkNpm(): void;
notify(customMessage?: UpdateNotifier.NotifyOptions): void;
}
export interface IUpdateInfo {
latest: string;
current: string;
type: string;
name: string;
}
interface Settings {
pkg?: Package;
callback?: (update?: UpdateInfo) => any;
packageName?: string;
packageVersion?: string;
updateCheckInterval?: number; // in milliseconds, default 1000 * 60 * 60 * 24 (1 day)
}
export declare class UpdateNotifier {
constructor(settings?: ISettings);
update: IUpdateInfo;
check(): void;
checkNpm(): void;
notify(customMessage?: INotifyOptions): void;
interface BoxenOptions {
padding: number;
margin: number;
align: string;
borderColor: string;
borderStyle: string;
}
interface NotifyOptions {
message: string;
defer?: boolean;
boxenOpts?: BoxenOptions;
}
interface Package {
name: string;
version: string;
}
interface UpdateInfo {
latest: string;
current: string;
type: string;
name: string;
}
}

View File

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

View File

@ -1,7 +1,6 @@
import UpdateNotifier = require("update-notifier");
import { UpdateNotifier } from "update-notifier";
var notifier = new UpdateNotifier();
var notifier = UpdateNotifier();
if (notifier.update) {
notifier.notify();
@ -9,7 +8,8 @@ if (notifier.update) {
console.log(notifier.update);
var notifier = new UpdateNotifier({
// Also exposed as a class
var notifier = new UpdateNotifier.UpdateNotifier({
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
});