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


TypeScript which類代碼示例

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


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

示例1: withSbt

export function withSbt(callback, globalState : vscode.Memento) {
    let configName = 'Ensime.sbtExec'
    let sbtCmd = vscode.workspace.getConfiguration(configName).toString() || globalState.get(configName)

    if(sbtCmd)
    {
        callback(sbtCmd)
    }
    else
    {
        //First check PATH
        which('sbt', (er, path) => {
            if(er)
            {
                //TODO: Give user option of manually locating sbt executable
                //Finally, make user manually get find sbtExec
                vscode.window.showErrorMessage("Could not find SBT executable. Please add SBT to %PATH% or using User Settings (Preferences -> User Settings)")
            }
            else
            {
                globalState.update(configName, path)
                callback(path)
            }
        })
    }
}
開發者ID:Mocuto,項目名稱:ensime-vscode,代碼行數:26,代碼來源:utils.ts

示例2: which

 return new Promise<string|null>(resolve => {
   which(name, (err, resolved) => {
     if (err) {
       resolve(null);
     } else {
       console.assert(resolved, '`which` didn\'t do what it should have.');
       resolve(resolved!);
     }
   });
 });
開發者ID:vector-of-bool,項目名稱:vscode-cmake-tools,代碼行數:10,代碼來源:paths.ts

示例3: executableExists

export function executableExists(
    command: string,
    callback: (err: NodeJS.ErrnoException | null, exists: boolean, resolvedPath: string | null) => void
) {
    which(command, (whichErr, _path) => {
        if (whichErr) {
            return callback(whichErr, false, null);
        }
        const path = Path.normalize(_path);
        fs.stat(path, (statErr, stats) => {
            if (statErr) {
                return callback(statErr, false, null);
            }
            const exists = stats.isFile();
            return callback(null, exists, exists ? path : null);
        });
    });
}
開發者ID:MarcelGerber,項目名稱:brackets-git,代碼行數:18,代碼來源:process-utils.ts


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