[getos] add typings (#18733)

This commit is contained in:
Dimitri Benin
2017-08-08 13:49:06 -07:00
committed by Mohamed Hegazy
parent d17782cacf
commit f340893290
4 changed files with 71 additions and 0 deletions
+18
View File
@@ -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;
}
});
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for getos 3.0
// Project: https://github.com/retrohacker/getos
// Definitions by: BendingBender <https://github.com/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;
}
}
+22
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }