diff --git a/types/getos/getos-tests.ts b/types/getos/getos-tests.ts new file mode 100644 index 0000000000..b1d5c2327c --- /dev/null +++ b/types/getos/getos-tests.ts @@ -0,0 +1,18 @@ +import getos = require('getos'); + +getos((e, os) => { + if (e) { + return; + } + + const thisOs: getos.Os = os; + + if (os.os === 'linux') { + let str: string; + let strn: string | undefined; + + str = os.dist; + str = os.release; + strn = os.codename; + } +}); diff --git a/types/getos/index.d.ts b/types/getos/index.d.ts new file mode 100644 index 0000000000..2b0048d006 --- /dev/null +++ b/types/getos/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for getos 3.0 +// Project: https://github.com/retrohacker/getos +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = getos; + +declare function getos(cb: (error: Error | null, os: getos.Os) => void): string; + +declare namespace getos { + type Os = OtherOs | LinuxOs; + + interface OtherOs { + os: 'aix' + | 'android' + | 'darwin' + | 'freebsd' + | 'openbsd' + | 'sunos' + | 'win32' + | 'cygwin'; + } + + interface LinuxOs { + os: 'linux'; + dist: string; + release: string; + codename?: string; + } +} diff --git a/types/getos/tsconfig.json b/types/getos/tsconfig.json new file mode 100644 index 0000000000..765383ed1c --- /dev/null +++ b/types/getos/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "getos-tests.ts" + ] +} diff --git a/types/getos/tslint.json b/types/getos/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/getos/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }