From 0e36eefc5fefe53784a5062666f4d818f676d930 Mon Sep 17 00:00:00 2001 From: Daniel Perez Alvarez Date: Fri, 7 Jul 2017 14:29:12 -0700 Subject: [PATCH] Update types for auto-launch v5.0.1 --- types/auto-launch/auto-launch-tests.ts | 35 ++++++------- types/auto-launch/index.d.ts | 72 ++++++++++++++------------ types/auto-launch/tsconfig.json | 4 +- types/auto-launch/tslint.json | 1 + 4 files changed, 59 insertions(+), 53 deletions(-) create mode 100644 types/auto-launch/tslint.json diff --git a/types/auto-launch/auto-launch-tests.ts b/types/auto-launch/auto-launch-tests.ts index ae6ace9620..af141358bd 100644 --- a/types/auto-launch/auto-launch-tests.ts +++ b/types/auto-launch/auto-launch-tests.ts @@ -1,24 +1,23 @@ - - import AutoLaunch = require('auto-launch'); -var a1 = new AutoLaunch({ - name: 'Foo', +const minecraftAutoLauncher = new AutoLaunch({ + name: 'Minecraft', + path: '/Applications/Minecraft.app', + mac: { + useLaunchAgent: true + } }); -var a2 = new AutoLaunch({ - name: 'Foo', - path: '/Applications/Foo.app', - isHidden: true, -}); +minecraftAutoLauncher.enable(); +minecraftAutoLauncher.disable(); -a1.enable(); -a2.disable(); - -a1.isEnabled(function(enabled: boolean) { - if (enabled) { - return; +minecraftAutoLauncher.isEnabled() + .then((isEnabled) => { + if (isEnabled) { + return; } - - a1.enable(function(err){ console.log(err.message); }); -}); + minecraftAutoLauncher.enable(); + }) + .catch((err) => { + console.error(err); + }); diff --git a/types/auto-launch/index.d.ts b/types/auto-launch/index.d.ts index 8a6af4e5dd..1ea4fcc25a 100644 --- a/types/auto-launch/index.d.ts +++ b/types/auto-launch/index.d.ts @@ -1,41 +1,47 @@ -// Type definitions for auto-launch 0.1.18 +// Type definitions for auto-launch 5.0 // Project: https://github.com/Teamwork/node-auto-launch -// Definitions by: rhysd +// Definitions by: rhysd , Daniel Perez Alvarez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface AutoLaunchOption { - /** - * Application name. - */ - name: string; - /** - * Hidden on launch or not. Default is false. - */ - isHidden?: boolean; - /** - * Path to application directory. - * Default is process.execPath. - */ - path?: string; +interface AutoLaunchOptions { + /** + * Application name. + */ + name: string; + /** + * Path to application. Default is `process.execPath`. + */ + path?: string; + /** + * Hidden on launch. Default is `false`. + */ + isHidden?: boolean; + /** + * For Mac-only options. + */ + mac?: { + /** + * By default, AppleScript is used to add a Login Item. If this is `true`, Launch Agent will be used to auto-launch your app. Defaults is `false`. + */ + useLaunchAgent?: boolean; + }; } declare class AutoLaunch { - constructor(opts: AutoLaunchOption); - /** - * Enables to launch at start up - */ - enable(callback?: (err: Error) => void): void; - /** - * Disables to launch at start up - */ - disable(callback?: (err: Error) => void): void; - /** - * Returns if auto start up is enabled - */ - isEnabled(callback: (enabled: boolean) => void): void; + constructor(options: AutoLaunchOptions); + + /** + * Enables auto-launch at start up. + */ + enable(): Promise; + /** + * Disables auto-launch at start up. + */ + disable(): Promise; + /** + * Returns true if auto-launch is enabled. + */ + isEnabled(): Promise; } -declare module "auto-launch" { - var al: typeof AutoLaunch; - export = al; -} +export = AutoLaunch; diff --git a/types/auto-launch/tsconfig.json b/types/auto-launch/tsconfig.json index 2200ea7a60..ba69bba12b 100644 --- a/types/auto-launch/tsconfig.json +++ b/types/auto-launch/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "index.d.ts", "auto-launch-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/auto-launch/tslint.json b/types/auto-launch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/auto-launch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }