• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra-p.stat函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fs-extra-p.stat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stat函数的具体用法?TypeScript stat怎么用?TypeScript stat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了stat函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: stat

 this.extraNuGetFileSources = BluebirdPromise.map(extraResources, file => {
   return stat(file)
     .then(it => {
       const relativePath = path.relative(appOutDir, file)
       const src = it.isDirectory() ? `${relativePath}${path.sep}**` : relativePath
       return `<file src="${src}" target="lib\\net45\\${relativePath.replace(/\//g, "\\")}"/>`
     })
 })
开发者ID:nickhudkins,项目名称:electron-builder,代码行数:8,代码来源:winPackager.ts


示例2: doesNotExist

  async doesNotExist() {
    try {
      await stat(this.path)
    }
    catch (e) {
      return
    }

    throw new Error(`Path ${this.path} must not exist`)
  }
开发者ID:EvgeneOskin,项目名称:electron-builder,代码行数:10,代码来源:fileAssert.ts


示例3: statOrNull

export async function statOrNull(file: string) {
  try {
    return await stat(file)
  }
  catch (e) {
    if (e.code === "ENOENT") {
      return null
    }
    else {
      throw e
    }
  }
}
开发者ID:Lange,项目名称:electron-builder,代码行数:13,代码来源:util.ts


示例4: upload

  // http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html
  async upload(task: UploadTask): Promise<any> {
    const fileName = path.basename(task.file)
    const cancellationToken = this.context.cancellationToken

    const target = (this.options.path == null ? "" : `${this.options.path}/`) + fileName

    if (process.env.__TEST_S3_PUBLISHER__ != null) {
      const testFile = path.join(process.env.__TEST_S3_PUBLISHER__!, target)
      await ensureDir(path.dirname(testFile))
      await symlink(task.file, testFile)
      return
    }

    const s3Options: CreateMultipartUploadRequest  = {
      Key: target,
      Bucket: this.getBucketName(),
      ContentType: mime.getType(task.file) || "application/octet-stream"
    }
    this.configureS3Options(s3Options)

    const contentLength = task.fileContent == null ? (await stat(task.file)).size : task.fileContent.length
    const uploader = new Uploader(new S3(this.createClientConfiguration()), s3Options, task.file, contentLength, task.fileContent)

    const progressBar = this.createProgressBar(fileName, uploader.contentLength)
    if (progressBar != null) {
      const callback = new ProgressCallback(progressBar)
      uploader.on("progress", () => {
        if (!cancellationToken.cancelled) {
          callback.update(uploader.loaded, uploader.contentLength)
        }
      })
    }

    return await cancellationToken.createPromise((resolve, reject, onCancel) => {
      onCancel(() => uploader.abort())
      uploader.upload()
        .then(() => {
          try {
            log.debug({provider: this.providerName, file: fileName, bucket: this.getBucketName()}, "uploaded")
          }
          finally {
            resolve()
          }
        })
        .catch(reject)
    })
  }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:48,代码来源:BaseS3Publisher.ts


示例5: upload

  // http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html
  async upload(file: string, arch: Arch, safeArtifactName?: string): Promise<any> {
    const fileName = path.basename(file)
    const fileStat = await stat(file)
    const cancellationToken = this.context.cancellationToken

    const target = (this.options.path == null ? "" : `${this.options.path}/`) + fileName

    if (process.env.__TEST_S3_PUBLISHER__ != null) {
      const testFile = path.join(process.env.__TEST_S3_PUBLISHER__!, target)
      await ensureDir(path.dirname(testFile))
      await symlink(file, testFile)
      return
    }

    const s3Options: CreateMultipartUploadRequest  = {
      Key: target,
      Bucket: this.getBucketName(),
      ContentType: mime.getType(file) || "application/octet-stream"
    }
    this.configureS3Options(s3Options)

    const uploader = new Uploader(new S3(this.createClientConfiguration()), s3Options, file, fileStat)

    const progressBar = this.createProgressBar(fileName, fileStat)
    if (progressBar != null) {
      const callback = new ProgressCallback(progressBar)
      uploader.on("progress", () => {
        if (!cancellationToken.cancelled) {
          callback.update(uploader.loaded, uploader.contentLength)
        }
      })
    }

    return cancellationToken.createPromise((resolve, reject, onCancel) => {
      onCancel(() => uploader.abort())
      uploader.upload()
        .then(() => {
          try {
            debug(`${this.providerName} Publisher: ${fileName} was uploaded to ${this.getBucketName()}`)
          }
          finally {
            resolve()
          }
        })
        .catch(reject)
    })
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:48,代码来源:basePublisher.ts


示例6: log

      new BluebirdPromise<any>(async (resolve, reject) => {
        log("Creating DMG")

        const specification: appdmg.Specification = Object.assign({
          title: this.appName,
          icon: path.join(this.buildResourcesDir, "icon.icns"),
          "icon-size": 80,
          contents: [
            {
              "x": 410, "y": 220, "type": "link", "path": "/Applications"
            },
            {
              "x": 130, "y": 220, "type": "file"
            }
          ]
        }, this.customBuildOptions)

        if (this.customBuildOptions == null || !("background" in this.customBuildOptions)) {
          const background = path.join(this.buildResourcesDir, "background.png")
          try {
            if ((await stat(background)).isFile()) {
              specification.background = background
            }
          }
          catch (e) {
            // ignored
          }
        }

        specification.contents[1].path = path.join(appOutDir, this.appName + ".app")

        const emitter = require("appdmg")({
          target: artifactPath,
          basepath: this.projectDir,
          specification: specification
        })
        emitter.on("error", reject)
        emitter.on("finish", () => resolve())
      })
开发者ID:atietje,项目名称:electron-builder,代码行数:39,代码来源:macPackager.ts


示例7: allCan

async function allCan(file: string, execute: boolean) {
  const mode = new Mode(await stat(file))

  function checkExecute(value: Permissions) {
    if (value.execute !== execute) {
      throw new Error(`${file} is ${execute ? "not " : ""}executable`)
    }
  }

  function checkRead(value: Permissions) {
    if (!value.read) {
      throw new Error(`${file} is not readable`)
    }
  }

  checkExecute(mode.owner)
  checkExecute(mode.group)
  checkExecute(mode.others)

  checkRead(mode.owner)
  checkRead(mode.group)
  checkRead(mode.others)
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:23,代码来源:filesTest.ts


示例8: isDirectory

 async isDirectory() {
   const info = await stat(this.path)
   if (!info.isDirectory()) {
     throw new Error(`Path ${this.path} is not a file`)
   }
 }
开发者ID:EvgeneOskin,项目名称:electron-builder,代码行数:6,代码来源:fileAssert.ts


示例9: upload

 async upload(file: string, artifactName?: string): Promise<any> {
   const fileName = artifactName || basename(file)
   const fileStat = await stat(file)
   await this.doUpload(fileName, fileStat.size, uploadFile.bind(this, file, fileStat, fileName))
 }
开发者ID:Icenium,项目名称:electron-builder,代码行数:5,代码来源:publisher.ts


示例10: test

 test('Cli - osx - no config file provided', async (t) => {
   await exec(['Example.app', '--platform=osx'])
   t.ok(await stat(exampleAppPath + '/Electron\ Builder\ Example.dmg'), 'dmg created')
   await remove(exampleAppPath + '/Electron\ Builder\ Example.dmg')
 })
开发者ID:EvgeneOskin,项目名称:electron-builder,代码行数:5,代码来源:old-cli-test.ts



注:本文中的fs-extra-p.stat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra-p.symlink函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra-p.rename函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap