本文整理汇总了TypeScript中fs-extra-p.Stats.isFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Stats.isFile方法的具体用法?TypeScript Stats.isFile怎么用?TypeScript Stats.isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs-extra-p.Stats
的用法示例。
在下文中一共展示了Stats.isFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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
}
}
}
示例3: 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)
}
}
示例4: isFile
async isFile() {
const info: Stats = await stat(this.actual)
if (!info.isFile()) {
throw new Error(`Path ${this.actual} is not a file`)
}
}