本文整理汇总了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;
}
示例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]);
}
}
示例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
}
}
}
示例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>()();
示例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;
}
示例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;
}
}
示例7: path
public static path(): string {
return `${osenv.home()}/.chullorc`;
}
示例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));