当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra-p.Stats类代码示例

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


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

示例1: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof (data as any).then === "function") {
          data = await data
        }

        if (data != null) {
          await writeFile(dest, data)
          return
        }
      }
    }
    const isUseHardLink = (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest)
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)
  }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:26,代码来源:fs.ts

示例2: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    try {
      if (this.transformer != null && stat != null && stat.isFile()) {
        let data = this.transformer(src)
        if (data != null) {
          if (typeof (data as any).then === "function") {
            data = await data
          }

          if (data != null) {
            await writeFile(dest, data)
            return
          }
        }
      }
      await copyOrLinkFile(src, dest, stat, (!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    }
    catch (e) {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (e.code === "EXDEV") {
        // ...but here we want to avoid excess debug log message
        if (this.isUseHardLink) {
          debug(`Cannot copy using hard link: ${e}`)
          this.isUseHardLink = false
        }

        await copyOrLinkFile(src, dest, stat, false)
      }
      else {
        throw e
      }
    }
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:33,代码来源:fs.ts

示例3: minimatchAll

// https://github.com/joshwnj/minimatch-all/blob/master/index.js
function minimatchAll(path: string, patterns: Array<Minimatch>, stat: Stats): boolean {
  let match = false
  for (const pattern of patterns) {
    // If we've got a match, only re-test for exclusions.
    // if we don't have a match, only re-test for inclusions.
    if (match !== pattern.negate) {
      continue
    }

    // partial match — pattern: foo/bar.txt path: foo — we must allow foo
    // use it only for non-negate patterns: const m = new Minimatch("!node_modules/@(electron-download|electron)/**/*", {dot: true }); m.match("node_modules", true) will return false, but must be true
    match = pattern.match(path, stat.isDirectory() && !pattern.negate)
  }
  return match
}
开发者ID:heinzbeinz,项目名称:electron-builder,代码行数:16,代码来源:filter.ts

示例4: copy

  async copy(src: string, dest: string, stat: Stats | undefined) {
    let afterCopyTransformer: AfterCopyFileTransformer | null = null
    if (this.transformer != null && stat != null && stat.isFile()) {
      let data = this.transformer(src)
      if (data != null) {
        if (typeof data === "object" && "then" in data) {
          data = await data
        }

        if (data != null) {
          if (data instanceof CopyFileTransformer) {
            afterCopyTransformer = data.afterCopyTransformer
          }
          else {
            await writeFile(dest, data)
            return
          }
        }
      }
    }

    const isUseHardLink = afterCopyTransformer == null && ((!this.isUseHardLink || this.isUseHardLinkFunction == null) ? this.isUseHardLink : this.isUseHardLinkFunction(dest))
    await copyOrLinkFile(src, dest, stat, isUseHardLink, isUseHardLink ? () => {
      // files are copied concurrently, so, we must not check here currentIsUseHardLink — our code can be executed after that other handler will set currentIsUseHardLink to false
      if (this.isUseHardLink) {
        this.isUseHardLink = false
        return true
      }
      else {
        return false
      }
    } : null)

    if (afterCopyTransformer != null) {
      await afterCopyTransformer(dest)
    }
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:37,代码来源:fs.ts

示例5: isDirectory

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

示例6: isFile

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

示例7: packageInDistributableFormat

  async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any> {
    let iconUrl = this.devMetadata.build.iconUrl
    if (!iconUrl) {
      if (this.customBuildOptions != null) {
        iconUrl = this.customBuildOptions.iconUrl
      }
      if (!iconUrl) {
        if (this.info.repositoryInfo != null) {
          const info = await this.info.repositoryInfo.getInfo(this)
          if (info != null) {
            iconUrl = `https://raw.githubusercontent.com/${info.user}/${info.project}/master/${this.relativeBuildResourcesDirname}/icon.ico`
          }
        }

        if (!iconUrl) {
          throw new Error("iconUrl is not specified, please see https://github.com/electron-userland/electron-builder#in-short")
        }
      }
    }

    const certificateFile = await this.certFilePromise
    const version = this.metadata.version
    const installerOutDir = WinPackager.computeDistOut(outDir, arch)
    const archSuffix = arch === "x64" ? "" : ("-" + arch)
    const options = Object.assign({
      name: this.metadata.name,
      productName: this.appName,
      exe: this.appName + ".exe",
      title: this.appName,
      appDirectory: appOutDir,
      outputDirectory: installerOutDir,
      version: version,
      description: this.metadata.description,
      authors: this.metadata.author.name,
      iconUrl: iconUrl,
      setupIcon: path.join(this.buildResourcesDir, "icon.ico"),
      certificateFile: certificateFile,
      certificatePassword: this.options.cscKeyPassword,
      fixUpPaths: false,
      usePackageJson: false,
      noMsi: true,
    }, this.customBuildOptions)

    try {
      await require("electron-winstaller-fixed").createWindowsInstaller(options)
    }
    catch (e) {
      if (!e.message.includes("Unable to set icon")) {
        throw e
      }
      else {
        let fileInfo: Stats
        try {
          fileInfo = await stat(options.setupIcon)
        }
        catch (e) {
          throw new Error("Please specify correct setupIcon, file " + options.setupIcon + " not found")
        }

        if (fileInfo.isDirectory()) {
          throw new Error("Please specify correct setupIcon, " + options.setupIcon + " is a directory")
        }
      }
    }

    const releasesFile = path.join(installerOutDir, "RELEASES")
    const nupkgPathOriginal = this.metadata.name + "-" + version + "-full.nupkg"
    const nupkgPathWithArch = this.metadata.name + "-" + version + archSuffix + "-full.nupkg"

    async function changeFileNameInTheReleasesFile(): Promise<void> {
      const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ")
      await writeFile(releasesFile, data)
    }

    const promises: Array<Promise<any>> = [
      rename(path.join(installerOutDir, "Setup.exe"), path.join(installerOutDir, `${this.appName}Setup-${version}${archSuffix}.exe`))
        .then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}Setup-${version}${archSuffix}.exe`)),
    ]

    if (archSuffix === "") {
      this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPathOriginal))
      this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
    }
    else {
      promises.push(
        rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
          .then(it => this.dispatchArtifactCreated(it))
      )
      promises.push(
        changeFileNameInTheReleasesFile()
          .then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
          .then(it => this.dispatchArtifactCreated(it))
      )
    }

    await BluebirdPromise.all(promises)
  }
开发者ID:bundyo,项目名称:electron-builder,代码行数:97,代码来源:winPackager.ts


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