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


TypeScript osenv.home函數代碼示例

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


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

示例1: loadNotebook

 loadNotebook(): Notebook {
     let existingNotes: Notebook = null;
     let savedNoteData: string = null;
     switch (this._noteStorageType) {
         case NoteStorageType.LocalStorage:
             savedNoteData = localStorage.getItem(savedNotesLocalStorageKey);
             break;
         case NoteStorageType.FileStorage:
             var fs = require("fs");
             var osenv = require("osenv");
             let noteDirectoryOnDisk = osenv.home() + "/.firenote/";
             let notebookDataFile = noteDirectoryOnDisk + savedNotesLocalStorageKey;
             if (!fs.existsSync(noteDirectoryOnDisk)) {
                 fs.mkdirSync(noteDirectoryOnDisk);
             }
             if (fs.existsSync(notebookDataFile)) {
                 savedNoteData = fs.readFileSync(notebookDataFile, "utf8");
             }
             break;
     }
     if (savedNoteData) {
         //Saved notes exist
         existingNotes = SerializationHelper.toInstance(new Notebook(), savedNoteData);
     }
     else {
         //reset notes and reload notebook
         this.reinitializeNotebook();
         existingNotes = this.loadNotebook();
     }
     return existingNotes;
 }
開發者ID:0xFireball,項目名稱:FireNote,代碼行數:31,代碼來源:storagemanager.ts

示例2: refreshApplication

	public async refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
		if (this.device.isEmulator) {
			const simulatorLogFilePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Library/Logs/system.log`);
			const simulatorLogFileContent = this.$fs.readText(simulatorLogFilePath) || "";

			const simulatorCachePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Containers/Data/Application/`);
			const regex = new RegExp(`^(?:.*?)${deviceAppData.appIdentifier}(?:.*?)${simulatorCachePath}(.*?)$`, "gm");

			let guid = "";
			while (true) {
				const parsed = regex.exec(simulatorLogFileContent);
				if (!parsed) {
					break;
				}

				guid = parsed[1];
			}

			if (!guid) {
				this.$errors.failWithoutHelp(`Unable to find application GUID for application ${deviceAppData.appIdentifier}. Make sure application is installed on Simulator.`);
			}

			const sourcePath = await deviceAppData.getDeviceProjectRootPath();
			const destinationPath = path.join(simulatorCachePath, guid, constants.LiveSyncConstants.IOS_PROJECT_PATH);

			this.$logger.trace(`Transferring from ${sourcePath} to ${destinationPath}`);
			shell.cp("-Rf", path.join(sourcePath, "*"), destinationPath);

			await this.device.applicationManager.restartApplication({ appId: deviceAppData.appIdentifier, projectName: "" });
		} else {
			await this.device.fileSystem.deleteFile("/Documents/AppBuilder/ServerInfo.plist", deviceAppData.appIdentifier);
			const notification = this.$project.projectData.Framework === constants.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript ? "com.telerik.app.refreshApp" : "com.telerik.app.refreshWebView";
			const notificationData = {
				deviceId: this.device.deviceInfo.identifier,
				notificationName: notification,
				commandType: constants.IOS_POST_NOTIFICATION_COMMAND_TYPE
			};
			await this.$iosDeviceOperations.postNotification([notificationData]);
		}
	}
開發者ID:telerik,項目名稱:mobile-cli-lib,代碼行數:40,代碼來源:ios-livesync-service.ts

示例3: constructor

	constructor($errors: IErrors,
		$staticConfig: IStaticConfig,
		$hostInfo: IHostInfo) {
		super({
			ipa: { type: OptionType.String },
			frameworkPath: { type: OptionType.String },
			frameworkName: { type: OptionType.String },
			framework: { type: OptionType.String },
			frameworkVersion: { type: OptionType.String },
			copyFrom: { type: OptionType.String },
			linkTo: { type: OptionType.String  },
			symlink: { type: OptionType.Boolean },
			forDevice: { type: OptionType.Boolean },
			client: { type: OptionType.Boolean, default: true},
			production: { type: OptionType.Boolean },
			debugTransport: {type: OptionType.Boolean},
			keyStorePath: { type: OptionType.String },
			keyStorePassword: { type: OptionType.String,},
			keyStoreAlias: { type: OptionType.String },
			keyStoreAliasPassword: { type: OptionType.String },
			ignoreScripts: {type: OptionType.Boolean },
			tnsModulesVersion: { type: OptionType.String },
			compileSdk: {type: OptionType.Number },
			port: { type: OptionType.Number },
			copyTo: { type: OptionType.String },
			baseConfig: { type: OptionType.String },
			platformTemplate: { type: OptionType.String },
			ng: {type: OptionType.Boolean },
			tsc: {type: OptionType.Boolean },
			bundle: {type: OptionType.Boolean },
			all: {type: OptionType.Boolean },
			teamId: { type: OptionType.String }
		},
		path.join($hostInfo.isWindows ? process.env.AppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
			$errors, $staticConfig);

		// On Windows we moved settings from LocalAppData to AppData. Move the existing file to keep the existing settings
		// I guess we can remove this code after some grace period, say after 1.7 is out
		if ($hostInfo.isWindows) {
			try {
				let shelljs = require("shelljs"),
					oldSettings = path.join(process.env.LocalAppData, ".nativescript-cli", "user-settings.json"),
					newSettings = path.join(process.env.AppData, ".nativescript-cli", "user-settings.json");
				if (shelljs.test("-e", oldSettings) && !shelljs.test("-e", newSettings)) {
					shelljs.mkdir(path.join(process.env.AppData, ".nativescript-cli"));
					shelljs.mv(oldSettings, newSettings);
				}
			} catch (err) {
				// ignore the error - it is too early to use $logger here
			}
		}
	}
開發者ID:JELaVallee,項目名稱:nativescript-cli,代碼行數:52,代碼來源:options.ts

示例4: return

		return (() => {
			if (this.device.isEmulator) {
				let simulatorLogFilePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Library/Logs/system.log`);
				let simulatorLogFileContent = this.$fs.readText(simulatorLogFilePath).wait() || "";

				let simulatorCachePath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${this.device.deviceInfo.identifier}/data/Containers/Data/Application/`);
				let regex = new RegExp(`^(?:.*?)${deviceAppData.appIdentifier}(?:.*?)${simulatorCachePath}(.*?)$`, "gm");

				let guid = "";
				while (true) {
					let parsed = regex.exec(simulatorLogFileContent);
					if (!parsed) {
						break;
					}
					guid = parsed[1];
				}

				if (!guid) {
					this.$errors.failWithoutHelp(`Unable to find application GUID for application ${deviceAppData.appIdentifier}. Make sure application is installed on Simulator.`);
				}

				let sourcePath = deviceAppData.deviceProjectRootPath;
				let destinationPath = path.join(simulatorCachePath, guid, LiveSyncConstants.IOS_PROJECT_PATH);

				this.$logger.trace(`Transferring from ${sourcePath} to ${destinationPath}`);
				shell.cp("-Rf", path.join(sourcePath, "*"), destinationPath);

				let cfBundleExecutable = `${this.$project.projectData.Framework}${this.$project.projectData.FrameworkVersion.split(".").join("")}`;
				this.device.applicationManager.restartApplication(deviceAppData.appIdentifier, cfBundleExecutable).wait();
			} else {
				this.device.fileSystem.deleteFile("/Library/Preferences/ServerInfo.plist", deviceAppData.appIdentifier);
				let notificationProxyClient = this.$injector.resolve(iOSProxyServices.NotificationProxyClient, {device: this.device});
				let notification = this.$project.projectData.Framework === this.$projectConstants.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript ? "com.telerik.app.refreshApp" : "com.telerik.app.refreshWebView";
				notificationProxyClient.postNotification(notification);
				notificationProxyClient.closeSocket();
			}

		}).future<void>()();
開發者ID:enchev,項目名稱:mobile-cli-lib,代碼行數:38,代碼來源:ios-livesync-service.ts

示例5: getInstalledApplications

export function getInstalledApplications(deviceId: string): IApplication[] {
	let rootApplicationsPath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${deviceId}/data/Containers/Bundle/Application`);
	if (!fs.existsSync(rootApplicationsPath)) {
		rootApplicationsPath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${deviceId}/data/Applications`);
	}
	let applicationGuids = fs.readdirSync(rootApplicationsPath);
	let result: IApplication[] = [];
	_.each(applicationGuids, applicationGuid => {
		let fullApplicationPath = path.join(rootApplicationsPath, applicationGuid);
		if (fs.statSync(fullApplicationPath).isDirectory()) {
			let applicationDirContents = fs.readdirSync(fullApplicationPath);
			let applicationName = _.find(applicationDirContents, fileName => path.extname(fileName) === ".app");
			let plistFilePath = path.join(fullApplicationPath, applicationName, "Info.plist");
			result.push({
				guid: applicationGuid,
				appIdentifier: getBundleIdentifier(plistFilePath),
				path: path.join(fullApplicationPath, applicationName)
			});
		}
	});

	return result;
}
開發者ID:telerik,項目名稱:ios-sim-portable,代碼行數:23,代碼來源:iphone-simulator-common.ts

示例6: saveNotebook

 saveNotebook(notebookToSave: Notebook) {
     let serializedNotebook: string = SerializationHelper.serialize(notebookToSave);
     switch (this._noteStorageType) {
         case NoteStorageType.LocalStorage:
             localStorage.setItem(savedNotesLocalStorageKey, serializedNotebook);
             break;
         case NoteStorageType.FileStorage:
             var fs = require("fs");
             var osenv = require("osenv");
             let noteDirectoryOnDisk = osenv.home() + "/.firenote/";
             let notebookDataFile = noteDirectoryOnDisk + savedNotesLocalStorageKey;
             if (!fs.existsSync(noteDirectoryOnDisk)) {
                 fs.mkdirSync(noteDirectoryOnDisk);
             }
             fs.writeFileSync(notebookDataFile, serializedNotebook); //asynchronously write file
             break;
     }
 }
開發者ID:0xFireball,項目名稱:FireNote,代碼行數:18,代碼來源:storagemanager.ts

示例7: path

 public static path(): string {
     return `${osenv.home()}/.chullorc`;
 }
開發者ID:victorjacobs,項目名稱:chullo-client,代碼行數:3,代碼來源:configuration.ts

示例8: load

import * as fs from 'fs';
import * as path from 'path';
import { home } from 'osenv';
import { read, getGalleryAPI } from './util';
import { validatePublisher } from './validation';
import * as denodeify from 'denodeify';

const readFile = denodeify<string, string, string>(fs.readFile);
const writeFile = denodeify<string, string, void>(fs.writeFile);
const storePath = path.join(home(), '.vsce');

export interface IPublisher {
	name: string;
	pat: string;
}

export interface IStore {
	publishers: IPublisher[];
}

export interface IGetOptions {
	promptToOverwrite?: boolean;
	promptIfMissing?: boolean;
}

function load(): Promise<IStore> {
	return readFile(storePath, 'utf8')
		.catch<string>(err => err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve('{}'))
		.then<IStore>(rawStore => {
			try {
				return Promise.resolve(JSON.parse(rawStore));
開發者ID:rlugojr,項目名稱:vscode-vsce,代碼行數:31,代碼來源:store.ts


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