本文整理汇总了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;
}
示例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\\""`
}
}
示例3: getExecutableExtention
function getExecutableExtention(): string {
if(os.type().match(/^Win/)){
return ".exe";
}
return "";
}
示例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')
})
示例5: getExecutableExtension
function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe';
}
return '';
}
示例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);
}
示例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)
}
示例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)
}
示例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);
}
});
}
示例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;
}