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


TypeScript fs-extra-p.stat函數代碼示例

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