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


TypeScript os.homedir函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。