os#type TypeScript Examples

The following examples show how to use os#type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: preview.ts    From vscode-openscad with GNU General Public License v3.0 6 votes vote down vote up
// Used to set the path to `openscad.exe` on the system. Necessary to open children
    public static setScadPath(scadPath?: string): void {
        // Set OpenSCAD path if specified; otherwise use system default
        Preview._scadPath = scadPath
            ? scadPath
            : pathByPlatform[type() as keyof typeof pathByPlatform];

        if (DEBUG) console.log(`Path: '${Preview._scadPath}'`); // DEBUG

        // Verify 'openscad' command is valid
        Preview._isValidScadPath = false; // Set to false until can test if the command exists
        commandExists(Preview._scadPath, (err: null, exists: boolean) => {
            Preview._isValidScadPath = exists;
        });
    }
Example #2
Source File: Normalize.ts    From nodetskeleton with MIT License 5 votes vote down vote up
static pathFromOS(path: string): string {
    return type() === "Windows_NT" ? path.replace(/\\/g, "/") : path;
  }
Example #3
Source File: ip.ts    From TidGi-Desktop with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Copy from https://github.com/silverwind/default-gateway 's index.js, to fix its weird behavior on windows. Its require statement will always require sunos
 * @returns
 */
async function defaultGatewayV4(): Promise<IDefaultGatewayInfo | undefined> {
  const plat = platform();

  if (supportedPlatforms.has(plat)) {
    let gatewayQueryFileName: NodeJS.Platform | 'ibmi' = plat;
    if (plat === 'aix') {
      gatewayQueryFileName = type() === 'OS400' ? 'ibmi' : 'sunos'; // AIX `netstat` output is compatible with Solaris
    }

    switch (gatewayQueryFileName) {
      case 'ibmi': {
        const defaultGateway = await import('default-gateway/ibmi');
        return await defaultGateway.v4();
      }
      case 'android': {
        const defaultGateway = await import('default-gateway/android');
        return await defaultGateway.v4();
      }
      case 'darwin': {
        const defaultGateway = await import('default-gateway/darwin');
        return await defaultGateway.v4();
      }
      case 'freebsd': {
        const defaultGateway = await import('default-gateway/freebsd');
        return await defaultGateway.v4();
      }
      case 'linux': {
        const defaultGateway = await import('default-gateway/linux');
        return await defaultGateway.v4();
      }
      case 'openbsd': {
        const defaultGateway = await import('default-gateway/openbsd');
        return await defaultGateway.v4();
      }
      case 'sunos': {
        const defaultGateway = await import('default-gateway/sunos');
        return await defaultGateway.v4();
      }
      case 'win32': {
        const defaultGateway = await import('default-gateway/win32');
        return await defaultGateway.v4();
      }
    }
  }
}