diff --git a/types/live-server/index.d.ts b/types/live-server/index.d.ts new file mode 100644 index 0000000000..630ff17120 --- /dev/null +++ b/types/live-server/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for live-server 1.2 +// Project: https://github.com/tapio/live-server#readme +// Definitions by: Josh Cummings +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * The live-server start params. + */ +export interface LiveServerParams { + /** Set the server port. Defaults to 8080. */ + port?: number; + /** Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP. */ + host?: string; + /** Set root directory that's being served. Defaults to cwd. */ + root?: string; + /** When false, it won't load your browser by default. */ + open?: boolean; + /** Comma-separated string for paths to ignore. */ + ignore?: string; + /** When set, serve this file (server root relative) for every 404 (useful for single-page applications). */ + file?: string; + /** Waits for all changes, before reloading. Defaults to 0 sec. */ + wait?: number; + /** Mount a directory to a route. */ + mount?: string[][]; + /** 0 = errors only, 1 = some, 2 = lots */ + logLevel?: 0 | 1 | 2; + /** Takes an array of Connect-compatible middleware that are injected into the server middleware stack. */ + middleware?: Array<(req: any, res: any, next: any) => void>; +} + +/** + * Start live-server. + */ +export function start(params: LiveServerParams): void; + +/** + * Shutdown live-server. + */ +export function shutdown(): void; diff --git a/types/live-server/live-server-tests.ts b/types/live-server/live-server-tests.ts new file mode 100644 index 0000000000..31a8224fc3 --- /dev/null +++ b/types/live-server/live-server-tests.ts @@ -0,0 +1,20 @@ +import liveServer = require('live-server'); + +liveServer.start({ + port: 8181, + host: '0.0.0.0', + root: '/public', + open: false, + ignore: 'scss,my/templates', + file: 'index.html', + wait: 1000, + mount: [['/components', './node_modules']], + logLevel: 2, + middleware: [ + (req: any, res: any, next: any) => { + next(); + }, + ], +}); + +liveServer.shutdown(); diff --git a/types/live-server/tsconfig.json b/types/live-server/tsconfig.json new file mode 100644 index 0000000000..2aff6f151b --- /dev/null +++ b/types/live-server/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "live-server-tests.ts" + ] +} diff --git a/types/live-server/tslint.json b/types/live-server/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/live-server/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }