當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript os.type函數代碼示例

本文整理匯總了TypeScript中os.type函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript type函數的具體用法?TypeScript type怎麽用?TypeScript type使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了type函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getUserHomePath

    public static getUserHomePath(): string {
        let homeDirectory: string = "";

        if (os.type() === "Darwin") {
            homeDirectory = process.env.HOME;
        } else if (os.type() === "Windows_NT") {
            homeDirectory = process.env.USERPROFILE;
        }

        return homeDirectory;
    }
開發者ID:ajwhite,項目名稱:vscode-react-native,代碼行數:11,代碼來源:intellisenseHelper.ts

示例2: getTerminalCommand

function getTerminalCommand() {
  if (os.type() === 'Windows_NT') {
    return 'start %s'
  } else if (os.type() === 'Linux') {
    return `x-terminal-emulator -e "bash -c \\"%s\\""`
  } else if (os.type() === 'Darwin') {
    return `osascript -e 'tell app "Terminal" to do script "%s"'`
  } else {
    // not recognised, hope xterm works
    return `xterm -e "bash -c \\"%s\\""`
  }
}
開發者ID:ThomasHickman,項目名稱:haskell-debug,代碼行數:12,代碼來源:config.ts

示例3: getExecutableExtention

function getExecutableExtention(): string {
    if(os.type().match(/^Win/)){
        return ".exe";
    }

    return "";
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:7,代碼來源:kubectlutility.ts

示例4: machineId

 return machineId().catch(() => {
   // In case MachineId fails
   const hash = crypto.createHash('sha256')
   const network = os.networkInterfaces()
   hash.update(os.arch() + os.hostname() + os.platform() + os.type() + network['mac'])
   return hash.digest('hex')
 })
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:7,代碼來源:stats.ts

示例5: getExecutableExtension

function getExecutableExtension(): string {
    if (os.type().match(/^Win/)) {
        return '.exe';
    }

     return '';
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:7,代碼來源:duffleinstaller.ts

示例6: enableSalsa

    /**
     * Helper method that sets the environment variable and informs the user they need to restart
     * in order to enable the Salsa intellisense.
     */
    public static enableSalsa(isRestartRequired: boolean): Q.Promise<boolean> {
        if (!process.env.VSCODE_TSJS) {
            let setEnvironmentVariableCommand: string = "";
            if (os.type() === "Darwin") {
                setEnvironmentVariableCommand = "launchctl setenv VSCODE_TSJS 1";
            } else if (os.type() === "Windows") {
                setEnvironmentVariableCommand = "setx VSCODE_TSJS 1";
            }

            return Q({})
                .then(() => Q.nfcall(child_process.exec, setEnvironmentVariableCommand))
                .then(() => { return true; });
        }

        return Q(isRestartRequired);
    }
開發者ID:ajwhite,項目名稱:vscode-react-native,代碼行數:20,代碼來源:intellisenseHelper.ts

示例7: handleError

export function handleError (error: Error, options: PrintOptions): any {
  let cause = (error as any).cause

  logError(error.message, 'message')

  while (cause) {
    logError(cause.message, 'caused by')

    cause = (cause as any).cause
  }

  if (options.verbose && error.stack) {
    log('')
    logError(error.stack, 'stack')
  }

  log('')
  logError(process.cwd(), 'cwd')
  logError(`${os.type()} ${os.release()}`, 'system')
  logError(process.argv.map(JSON.stringify).join(' '), 'command')
  logError(process.version, 'node -v')
  logError(pkg.version, `typings -v`)

  if ((error as any).code) {
    logError((error as any).code, 'code')
  }

  log('')
  logError('If you need help, you may report this error at:')
  logError(`  <https://github.com/typings/typings/issues>`)

  process.exit(1)
}
開發者ID:AndreiShostik,項目名稱:typings,代碼行數:33,代碼來源:cli.ts

示例8: handleError

export function handleError (error: BaseError, options: PrintOptions): any {
  let message = ''
  let cause = error

  message += logError(error.message, 'message')

  while (cause = cause.cause as any) {
    message += logError(cause.message, 'caused by')
  }

  if (options.verbose && error.stack) {
    message += '\n'
    message += logError(error.stack, 'stack')
  }

  message += '\n'
  message += logError(process.cwd(), 'cwd')
  message += logError(`${os.type()} ${os.release()}`, 'system')
  message += logError(process.argv.map(JSON.stringify).join(' '), 'command')
  message += logError(process.version, 'node -v')
  message += logError(pkg.version, `${PROJECT_NAME} -v`)

  if ((error as any).code) {
    message += logError((error as any).code, 'code')
  }

  message += '\n'
  message += logError('If you need help, you may report this error at:')
  message += logError(`  <${ISSUES_HOMEPAGE}>`)

  console.error(message)
  process.exit(1)
}
開發者ID:bitjson,項目名稱:typings,代碼行數:33,代碼來源:cli.ts

示例9: downloadBinary

 /**
  * Download the binary file.
  * @param binary The binary of interest.
  * @param outputDir The directory where files are downloaded and stored.
  * @param opt_proxy The proxy for downloading files.
  * @param opt_ignoreSSL To ignore SSL.
  * @param opt_callback Callback method to be executed after the file is downloaded.
  */
 static downloadBinary(
     binary: Binary, outputDir: string, opt_proxy?: string,
     opt_ignoreSSL?: boolean, opt_callback?: Function): void {
   logger.info(binary.name + ': downloading version ' + binary.version());
   var url = binary.url(os.type(), os.arch());
   if (!url) {
     logger.error(binary.name + ' v' + binary.version() + ' is not available for your system.');
     return;
   }
   Downloader.httpGetFile_(
       url, binary.filename(os.type(), os.arch()), outputDir, opt_proxy, opt_ignoreSSL, (filePath: string) => {
         if (opt_callback) {
           opt_callback(binary, outputDir, filePath);
         }
       });
 }
開發者ID:rayrapetyan,項目名稱:webdriver-manager,代碼行數:24,代碼來源:downloader.ts

示例10: env

export function env(): any {
    let env = Object.assign({}, process.env);

    if (os.type() == 'Darwin') {
        env.PATH = `${ROOT}/bin:${env.PATH}`;
    } else if (os.type() == 'Linux') {
        if (os.arch() == 'x64') {

        } else {

        }
    } else if (os.type() == 'Windows_NT') {
        env.Path =  `${ROOT}/bin;${env.Path}`;
    }

    return env;
}
開發者ID:Romakita,項目名稱:e2e-app,代碼行數:17,代碼來源:env.ts


注:本文中的os.type函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。