本文整理汇总了TypeScript中os.homedir函数的典型用法代码示例。如果您正苦于以下问题:TypeScript homedir函数的具体用法?TypeScript homedir怎么用?TypeScript homedir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了homedir函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: globalConfigFilePath
static globalConfigFilePath(): string {
const globalConfigPath = path.join(homedir(), CLI_CONFIG_FILE_NAME);
if (fs.existsSync(globalConfigPath)) {
return globalConfigPath;
}
const altGlobalConfigPath = path.join(homedir(), CLI_CONFIG_FILE_NAME_ALT);
if (fs.existsSync(altGlobalConfigPath)) {
return altGlobalConfigPath;
}
return globalConfigPath;
}
开发者ID:RicardoVaranda,项目名称:angular-cli,代码行数:13,代码来源:config.ts
示例2: registerProtocolForLinux
function registerProtocolForLinux() {
const desktopFilePath = os.homedir() + "/.local/share/applications/appimagekit-rabix-composer.desktop";
const configMimeFilePath = os.homedir() + "/.config/mimeapps.list";
const localMimeFilePath = os.homedir() + "/.local/share/applications/mimeapps.list";
const xSchemeHandler = "x-scheme-handler/rabix-composer";
// Read desktop file (appimagekit-rabix-composer.desktop)
fs.readFile(desktopFilePath, "utf8", (err, data) => {
if (err) {
return;
}
const hasMimeType = ~data.indexOf("MimeType=");
// If there is no MimeType already set (first time starting application)
if (!hasMimeType) {
// Append MimeType=x-scheme-handler/rabix-composer handler to the end of a file
fs.appendFile(desktopFilePath, "MimeType=" + xSchemeHandler, () => {
});
}
// Open .config/mimeapps.list file
fs.readFile(configMimeFilePath, "utf8", (err, configMimeFileContent) => {
if (err) {
// In case .config/mimeapps.list file does not exist, open .local/share/applications/mimeapps.list file
fs.readFile(localMimeFilePath, "utf8", (err, localMimeFileContent) => {
if (err) {
return;
}
// Update .config/mimeapps.list with rabix-composer x-scheme-handler
updateMimeAppsListFile(localMimeFileContent, localMimeFilePath)
});
return;
}
// Update .local/share/applications/mimeapps.list with rabix-composer x-scheme-handler
updateMimeAppsListFile(configMimeFileContent, configMimeFilePath);
});
});
}
开发者ID:hmenager,项目名称:composer,代码行数:49,代码来源:register-protocols.ts
示例3: DotNetPath
function DotNetPath() {
// try global installation directory
let result = path.join(homedir(), ".autorest", "frameworks", "dotnet")
if (fs.existsSync(result)) {
return result;
}
result = path.join(homedir(), ".autorest", "frameworks", "dotnet.exe")
if (fs.existsSync(result)) {
return result;
}
// hope there is one in the PATH
return "dotnet";
}
开发者ID:amarzavery,项目名称:AutoRest,代码行数:15,代码来源:autorest-dotnet.ts
示例4: clone
@command('git.clone')
async clone(): Promise<void> {
const url = await window.showInputBox({
prompt: localize('repourl', "Repository URL"),
ignoreFocusOut: true
});
if (!url) {
return;
}
const parentPath = await window.showInputBox({
prompt: localize('parent', "Parent Directory"),
value: os.homedir(),
ignoreFocusOut: true
});
if (!parentPath) {
return;
}
const clonePromise = this.model.git.clone(url, parentPath);
window.setStatusBarMessage(localize('cloning', "Cloning git repository..."), clonePromise);
const repositoryPath = await clonePromise;
const open = localize('openrepo', "Open Repository");
const result = await window.showInformationMessage(localize('proposeopen', "Would you like to open the cloned repository?"), open);
if (result === open) {
commands.executeCommand('vscode.openFolder', Uri.file(repositoryPath));
}
}
开发者ID:yuit,项目名称:vscode,代码行数:32,代码来源:commands.ts
示例5: constructor
constructor(params) {
const { path, createIfMissing, errorIfExists } = params;
let basePath;
if (!path) {
basePath = `${os.homedir()}/.bitcore`;
try {
fs.mkdirSync(basePath);
} catch (e) {
if (e.errno !== -17) {
console.error('Unable to create bitcore storage directory');
}
}
}
this.path = path || `${basePath}/bitcoreWallet`;
if (!createIfMissing) {
const walletExists =
fs.existsSync(this.path) &&
fs.existsSync(this.path + '/LOCK') &&
fs.existsSync(this.path + '/LOG');
if (!walletExists) {
throw new Error('Not a valid wallet path');
}
}
if (StorageCache[this.path]) {
this.db = StorageCache[this.path];
} else {
this.db = StorageCache[this.path] = levelup(leveldown(this.path), {
createIfMissing,
errorIfExists
});
}
}
开发者ID:bitjson,项目名称:bitcore,代码行数:32,代码来源:storage.ts
示例6: if
let disposable = vscode.commands.registerCommand('extension.codeFileNav', () => {
const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('codeFileNav');
const defaultFolders: string[] = config.get('defaultFolder', '').split('|');
const editor: vscode.TextEditor = vscode.window.activeTextEditor;
const workspaceFolder: string = vscode.workspace.rootPath;
let dir: string = '';
defaultFolders.forEach(defaultFolder => {
if (dir) { return; }
defaultFolder = defaultFolder
.toLowerCase()
.replace(/\${home}/gi, os.homedir());
if (defaultFolder === '${folder}' && editor && editor.document.fileName) {
dir = path.dirname(editor.document.fileName);
} else if (defaultFolder === '${workspace}' && workspaceFolder) {
dir = workspaceFolder;
} else {
try {
fs.accessSync(defaultFolder);
dir = defaultFolder;
} catch (err) { }
}
});
if (!dir) {
dir = os.homedir();
}
codeFileNav.showFileList(dir);
});
开发者ID:jakelucas,项目名称:code-file-nav,代码行数:33,代码来源:extension.ts
示例7: before
before(async function () {
const app = this.app as SpectronApplication;
if (app.quality === Quality.Dev) {
const extensionsPath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions');
const debugPath = path.join(extensionsPath, 'vscode-node-debug');
const debugExists = fs.existsSync(debugPath);
const debug2Path = path.join(extensionsPath, 'vscode-node-debug2');
const debug2Exists = fs.existsSync(debug2Path);
if (!debugExists) {
console.warn(`Skipping debug tests because vscode-node-debug extension was not found in ${extensionsPath}`);
return;
}
if (!debug2Exists) {
console.warn(`Skipping debug tests because vscode-node-debug2 extension was not found in ${extensionsPath}`);
return;
}
await new Promise((c, e) => fs.symlink(debugPath, path.join(app.extensionsPath, 'vscode-node-debug'), err => err ? e(err) : c()));
await new Promise((c, e) => fs.symlink(debug2Path, path.join(app.extensionsPath, 'vscode-node-debug2'), err => err ? e(err) : c()));
await app.reload();
}
this.app.suiteName = 'Debug';
});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:29,代码来源:debug.test.ts
示例8: getCwd
export function getCwd(shell: IShellLaunchConfig, root: Uri, configHelper: ITerminalConfigHelper): string {
if (shell.cwd) {
return shell.cwd;
}
let cwd: string;
// TODO: Handle non-existent customCwd
if (!shell.ignoreConfigurationCwd) {
// Evaluate custom cwd first
const customCwd = configHelper.config.cwd;
if (customCwd) {
if (paths.isAbsolute(customCwd)) {
cwd = customCwd;
} else if (root) {
cwd = paths.normalize(paths.join(root.fsPath, customCwd));
}
}
}
// If there was no custom cwd or it was relative with no workspace
if (!cwd) {
cwd = root ? root.fsPath : os.homedir();
}
return _sanitizeCwd(cwd);
}
开发者ID:ramesius,项目名称:vscode,代码行数:27,代码来源:terminalEnvironment.ts
示例9: deleteOldElectronVersion
async function deleteOldElectronVersion(): Promise<any> {
if (!process.env.CI) {
return
}
const cacheDir = path.join(homedir(), ".electron")
try {
const deletePromises: Array<Promise<any>> = []
for (let file of (await readdir(cacheDir))) {
if (file.endsWith(".zip") && !file.includes(ELECTRON_VERSION)) {
console.log(`Remove old electron ${file}`)
deletePromises.push(unlink(path.join(cacheDir, file)))
}
}
return await BluebirdPromise.all(deletePromises)
}
catch (e) {
if (e.code === "ENOENT") {
return []
}
else {
throw e
}
}
}
开发者ID:aulvi,项目名称:electron-builder,代码行数:25,代码来源:runTests.ts
示例10: NewTestingServer
export function NewTestingServer(conf:any) {
const host = conf.host ||Â HOST
const port = conf.port ||Â PORT++
const commonConf = {
nobma: false,
bmaWithCrawler: true,
port: port,
ipv4: host,
remoteipv4: host,
currency: conf.currency || CURRENCY_NAME,
httpLogs: true,
forksize: conf.forksize || 3,
};
if (conf.sigQty === undefined) {
conf.sigQty = 1;
}
// Disable UPnP during tests
if (!conf.ws2p) {
conf.ws2p = { upnp: false }
}
Object.keys(commonConf).forEach(k => conf[k] = (commonConf as any)[k])
const server = new Server(
path.resolve(path.join(os.homedir(), '/.config/duniter/' + (conf.homename || 'dev_unit_tests'))),
conf.memory !== undefined ? conf.memory : MEMORY_MODE,
conf);
return new TestingServer(port, server)
}
开发者ID:duniter,项目名称:remuniter,代码行数:28,代码来源:test-tools.ts
注:本文中的os.homedir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论