当前位置: 首页>>代码示例>>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;未经允许,请勿转载。