本文整理匯總了TypeScript中os.platform函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript platform函數的具體用法?TypeScript platform怎麽用?TypeScript platform使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了platform函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildPlaceholderFindCommand
/** Builds the command that will be executed to find all files containing version placeholders. */
function buildPlaceholderFindCommand(packageDir: string) {
if (platform() === 'win32') {
return {
binary: 'findstr',
args: ['/msi', `${ngVersionPlaceholderText} ${versionPlaceholderText}`, `${packageDir}\\*`]
};
} else {
return {
binary: 'grep',
args: ['-ril', `${ngVersionPlaceholderText}\\|${versionPlaceholderText}`, packageDir]
};
}
}
示例2: _appDirectory
private _appDirectory(): string {
var dir;
switch (os.platform()) {
case 'win32':
break;
case 'darwin':
dir = '/Applications/Sublime Text 2.app/Contents'
break;
default:
dir = null;
}
return dir;
}
示例3: postConstruct
@postConstruct()
public postConstruct() {
this.headers = {
broadhash : this.appConfig.nethash,
firewalled: this.appConfig.forging.transactionsPolling ? 'true' : 'false',
height : 1,
nethash : this.appConfig.nethash,
nonce : this.nonce,
os : `${os.platform()}${os.release()}`,
port : this.appConfig.port,
version : this.appConfig.version,
};
}
示例4: help
help(): string {
const executable = 'code' + (os.platform() === 'win32' ? '.exe' : '');
return `Visual Studio Code v${ packageJson.version }
Usage: ${ executable } [arguments] [paths...]
Options:
-h, --help Print usage.
--locale Use a specific locale.
-n Force a new instance of Code.
-v, --version Print version.`;
}
示例5: buildPackageImportStatementFindCommand
/** Builds the command that will be executed to find all import statements for a package. */
function buildPackageImportStatementFindCommand(searchDirectory: string, packageName: string) {
if (platform() === 'win32') {
return {
binary: 'findstr',
args: ['/r', `from.'@angular-mdc/${packageName}/.*'`, `${searchDirectory}\\*.ts`]
};
} else {
return {
binary: 'grep',
args: ['-Eroh', '--include', '*.ts', `from '@angular-mdc/${packageName}/.+';`, searchDirectory]
};
}
}
示例6: debug
public async debug(debugData: IDebugData, options: IDebugOptions): Promise<IDebugInformation> {
const device = this.$devicesService.getDeviceByIdentifier(debugData.deviceIdentifier);
if (!device) {
this.$errors.failWithoutHelp(`Cannot find device with identifier ${debugData.deviceIdentifier}.`);
}
if (device.deviceInfo.status !== CONNECTED_STATUS) {
this.$errors.failWithoutHelp(`The device with identifier ${debugData.deviceIdentifier} is unreachable. Make sure it is Trusted and try again.`);
}
await this.$analyticsService.trackEventActionInGoogleAnalytics({
action: TrackActionNames.Debug,
device,
additionalData: this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) && options && options.inspector ? DebugTools.Inspector : DebugTools.Chrome,
projectDir: debugData.projectDir
});
if (!(await device.applicationManager.isApplicationInstalled(debugData.applicationIdentifier))) {
this.$errors.failWithoutHelp(`The application ${debugData.applicationIdentifier} is not installed on device with identifier ${debugData.deviceIdentifier}.`);
}
const debugOptions: IDebugOptions = _.cloneDeep(options);
// TODO: Check if app is running.
// For now we can only check if app is running on Android.
// After we find a way to check on iOS we should use it here.
let result: string;
const debugService = this.getDebugService(device);
if (!debugService) {
this.$errors.failWithoutHelp(`Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`);
}
// TODO: Consider to move this code to ios-debug-service
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
if (device.isEmulator && !debugData.pathToAppPackage && debugOptions.debugBrk) {
this.$errors.failWithoutHelp("To debug on iOS simulator you need to provide path to the app package.");
}
if (this.$hostInfo.isWindows) {
debugOptions.emulator = false;
} else if (!this.$hostInfo.isDarwin) {
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
}
}
result = await debugService.debug(debugData, debugOptions);
return this.getDebugInformation(result, device.deviceInfo.identifier);
}
示例7: GenerateOptionsSchema
export function GenerateOptionsSchema() {
let packageJSON: any = JSON.parse(fs.readFileSync('package.json').toString());
let schemaJSON: any = JSON.parse(fs.readFileSync('src/tools/OptionsSchema.json').toString());
let symbolSettingsJSON: any = JSON.parse(fs.readFileSync('src/tools/VSSymbolSettings.json').toString());
mergeReferences(schemaJSON.definitions, symbolSettingsJSON.definitions);
schemaJSON.definitions = ReplaceReferences(schemaJSON.definitions, schemaJSON.definitions);
// Hard Code adding in configurationAttributes launch and attach.
// .NET Core
packageJSON.contributes.debuggers[0].configurationAttributes.launch = schemaJSON.definitions.LaunchOptions;
packageJSON.contributes.debuggers[0].configurationAttributes.attach = schemaJSON.definitions.AttachOptions;
// Full .NET Framework
packageJSON.contributes.debuggers[1].configurationAttributes.launch = schemaJSON.definitions.LaunchOptions;
packageJSON.contributes.debuggers[1].configurationAttributes.attach = schemaJSON.definitions.AttachOptions;
// Make a copy of the options for unit test debugging
let unitTestDebuggingOptions = JSON.parse(JSON.stringify(schemaJSON.definitions.AttachOptions.properties));
// Remove the options we don't want
delete unitTestDebuggingOptions.processName;
delete unitTestDebuggingOptions.processId;
delete unitTestDebuggingOptions.pipeTransport;
// Add the additional options we do want
unitTestDebuggingOptions["type"] = {
"type": "string",
"enum": [
"coreclr",
"clr"
],
"description": "Type type of code to debug. Can be either 'coreclr' for .NET Core debugging, or 'clr' for Desktop .NET Framework. 'clr' only works on Windows as the Desktop framework is Windows-only.",
"default": "coreclr"
};
unitTestDebuggingOptions["debugServer"] = {
"type": "number",
"description": "For debug extension development only: if a port is specified VS Code tries to connect to a debug adapter running in server mode",
"default": 4711
};
packageJSON.contributes.configuration.properties["csharp.unitTestDebuggingOptions"].properties = unitTestDebuggingOptions;
let content = JSON.stringify(packageJSON, null, 2);
if (os.platform() === 'win32') {
content = content.replace(/\n/gm, "\r\n");
}
// We use '\u200b' (unicode zero-length space character) to break VS Code's URL detection regex for URLs that are examples. This process will
// convert that from the readable espace sequence, to just an invisible character. Convert it back to the visible espace sequence.
content = content.replace(/\u200b/gm, "\\u200b");
fs.writeFileSync('package.json', content);
}
示例8: removeUnnecessaryFile
function removeUnnecessaryFile(): Promise<void> {
if (os.platform() !== 'win32') {
let sourcePath: string = util.getDebugAdaptersPath("bin/OpenDebugAD7.exe.config");
if (fs.existsSync(sourcePath)) {
fs.rename(sourcePath, util.getDebugAdaptersPath("bin/OpenDebugAD7.exe.config.unused"), (err: NodeJS.ErrnoException) => {
if (err) {
getOutputChannelLogger().appendLine(`ERROR: fs.rename failed with "${err.message}". Delete ${sourcePath} manually to enable debugging.`);
}
});
}
}
return Promise.resolve();
}
示例9:
}).then(answer => {
const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('codeFileNav');
const platform: string = os.platform();
const rFlag: string = answer === 'Open in a new window' ? '-n' : '-r';
const folderPath: string = data.cwd.includes(' ') ? `"${data.cwd}"` : data.cwd;
const platformCodePath: string = config.get(`codePath.${platform}`, 'code');
const codePath: string = platformCodePath.includes(' ') ? `"${platformCodePath}"` : platformCodePath;
child_process.exec(`${codePath} ${folderPath} ${rFlag}`, err => {
if (err) {
vscode.window.showErrorMessage(`Error: Ensure that your 'codeFileNav.codePath.${platform}' configuration is correct.`)
}
});
});
示例10: connectSocket
function connectSocket(socket: net.Socket): net.Socket {
let u = discoverUrl();
if (u.protocol == 'tcp:' && u.port) {
socket.connect(+u.port, '127.0.0.1');
} else if (u.protocol == 'local:' && u.hostname && os.platform() == 'win32') {
let pipePath = '\\\\.\\pipe\\' + u.hostname;
socket.connect(pipePath);
} else if (u.protocol == 'local:' && u.path) {
socket.connect(u.path);
} else {
throw 'Unknown protocol ' + u.protocol;
}
return socket;
}