mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Vendored
+57
@@ -0,0 +1,57 @@
|
||||
// Type definitions for nssm 0.1
|
||||
// Project: https://github.com/alykoshin/nssm
|
||||
// Definitions by: Joram van den Boezem <https://github.com/hongaar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
type Command =
|
||||
| 'install'
|
||||
| 'remove'
|
||||
| 'start'
|
||||
| 'stop'
|
||||
| 'restart'
|
||||
| 'status'
|
||||
| 'pause'
|
||||
| 'continue'
|
||||
| 'rotate'
|
||||
| 'get'
|
||||
| 'set'
|
||||
| 'reset';
|
||||
|
||||
type NssmThen<T> = <TResult1 = T, TResult2 = never>(
|
||||
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
||||
onrejected?: ((reason: Error, stderr: string) => TResult2 | PromiseLike<TResult2>) | null
|
||||
) => NssmPromise<TResult1 | TResult2>;
|
||||
|
||||
type NssmCatch<T> = <TResult = never>(
|
||||
onrejected?: ((reason: Error, stderr: string) => TResult | PromiseLike<TResult>) | null
|
||||
) => NssmPromise<T | TResult>;
|
||||
|
||||
interface NssmPromise<T> extends Promise<T> {
|
||||
then: NssmThen<T>;
|
||||
catch: NssmCatch<T>;
|
||||
}
|
||||
|
||||
type CallbackFn = (error?: string, result?: string) => void;
|
||||
type ZeroArgCommandFn = (callback: CallbackFn) => void;
|
||||
type OneArgCommandFn = (arg1: string, callback: CallbackFn) => void;
|
||||
type TwoArgCommandFn = (arg1: string, arg2: string, callback: CallbackFn) => void;
|
||||
type PromiseCommandFn = (arg1?: string, arg2?: string) => NssmPromise<string>;
|
||||
|
||||
type NssmCommandFn =
|
||||
& ZeroArgCommandFn
|
||||
& OneArgCommandFn
|
||||
& TwoArgCommandFn
|
||||
& PromiseCommandFn;
|
||||
|
||||
type Nssm = {
|
||||
[key in Command]: NssmCommandFn
|
||||
};
|
||||
|
||||
interface NssmOptions {
|
||||
nssmExe?: string;
|
||||
}
|
||||
|
||||
declare function nssm(serviceName: string, options?: NssmOptions): Nssm;
|
||||
|
||||
export = nssm;
|
||||
@@ -0,0 +1,42 @@
|
||||
// https://github.com/alykoshin/nssm/blob/master/examples/promise_chain.js
|
||||
|
||||
import nssm = require('nssm');
|
||||
|
||||
const svcName = 'test';
|
||||
const options = { nssmExe: 'nssm.exe' };
|
||||
const testService = nssm(svcName, options);
|
||||
|
||||
const propertyName = 'Start';
|
||||
|
||||
const console: { log: (...message: any[]) => void } = { log: (...args) => void (args) };
|
||||
|
||||
testService.set('start', 'manual')
|
||||
.then((stdout) => {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
return testService.get('start');
|
||||
})
|
||||
.then((stdout) => {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
return testService.start();
|
||||
})
|
||||
.then((stdout) => {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
return testService.stop();
|
||||
})
|
||||
.then((stdout) => {
|
||||
console.log(`stdout: ${stdout}`);
|
||||
})
|
||||
.catch((error, stdout) => {
|
||||
console.log(`error: ${error}, stdout: ${stdout}`);
|
||||
})
|
||||
;
|
||||
|
||||
// https://github.com/alykoshin/nssm/blob/master/examples/get_callback.js
|
||||
|
||||
testService.get(propertyName, (error, stdout) => {
|
||||
if (error) {
|
||||
console.log('error:', error, ' stderr:', stdout);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
@@ -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",
|
||||
"nssm-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user