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


TypeScript fs-extra-promise.readFileSync函數代碼示例

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


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

示例1: hasWebServerDependency

function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
    if (!targetProjectData || !targetProjectData.projectJsonPath) {
        return false;
    }

    let projectJson = fs.readFileSync(targetProjectData.projectJsonPath.fsPath, 'utf8');
    projectJson = projectJson.replace(/^\uFEFF/, '');

    let projectJsonObject: any;

    try {
        // TODO: This error should be surfaced to the user. If the JSON can't be parsed
        // (maybe due to a syntax error like an extra comma), the user should be notified
        // to fix up their project.json.
        projectJsonObject = JSON.parse(projectJson);
    } catch (error) {
        projectJsonObject = null;
    }

    if (projectJsonObject == null) {
        return false;
    }
    
    for (var key in projectJsonObject.dependencies) {
        if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
            return true;
        }
    }
    
    return false;
}
開發者ID:Firaenix,項目名稱:omnisharp-vscode,代碼行數:31,代碼來源:assets.ts

示例2: formatByTimestamp

function formatByTimestamp() {

  const FIVE_MINUTES = 1000 * 60 * 5
  const timestampPath = jd('timestamp.txt')
  const now = new Date()

  if (fsep.existsSync(timestampPath)) {

    const oldTimestamp = fsep.readFileSync(timestampPath).toString()
    const oldDate = new Date(oldTimestamp)
    const difference = now.valueOf() - oldDate.valueOf()

    if (difference > FIVE_MINUTES) {
      log('Running 5 minute code format')
      updateTimestamp()
      soFormatDefinitely()
    } else {
      log(ms(FIVE_MINUTES - difference) + ' to next format')
      return
    }

  }

  updateTimestamp()

  function updateTimestamp() {
    fsep.writeFileSync(timestampPath, now.toISOString())
  }

}
開發者ID:Edward-Lombe,項目名稱:elm-electron,代碼行數:30,代碼來源:maybe-format.ts

示例3: elmxMake

export function elmxMake(inputFile: string, outputFile: string): void {

  const elmx = require('elmx')

  const elmxFile = fsep.readFileSync(inputFile).toString()

  const elmSource = elmx(elmxFile)

  fsep.writeFileSync(outputFile, elmSource)

}
開發者ID:Edward-Lombe,項目名稱:elm-electron,代碼行數:11,代碼來源:elm-make.ts

示例4: addApiExportedFlag

export function addApiExportedFlag(iterator: ObjectIterator) {
  const baseModule = findBaseModule(iterator.modules);

  let tsFile = readFileSync(baseModule.originalName, "utf-8");
  let exportedFromAnotherModule = parseExportClause(tsFile);
  let exportedInBaseModule = (id) => id > baseModule.id && id < iterator.lastId;

  iterator.addFlags({ isApiExported: true }, (obj) => {
    return obj.flags.isExported &&
      (exportedFromAnotherModule.indexOf(obj.name) > -1 ||
        exportedInBaseModule(obj.id))
  });
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:13,代碼來源:find-real-api.ts

示例5: hasWebServerDependency

function hasWebServerDependency(projectJsonPath: string) {
    let projectJson = fs.readFileSync(projectJsonPath, 'utf8');
    let projectJsonObject = JSON.parse(projectJson);
    
    if (projectJsonObject == null) {
        return false;
    }
    
    for (var key in projectJsonObject.dependencies) {
        if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
            return true;
        }
    }
    
    return false;    
}
開發者ID:bertlacy,項目名稱:omnisharp-vscode,代碼行數:16,代碼來源:assets.ts


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