本文整理汇总了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, "\\")}"/>`
})
})
示例2: doesNotExist
async doesNotExist() {
try {
await stat(this.path)
}
catch (e) {
return
}
throw new Error(`Path ${this.path} must not exist`)
}
示例3: statOrNull
export async function statOrNull(file: string) {
try {
return await stat(file)
}
catch (e) {
if (e.code === "ENOENT") {
return null
}
else {
throw e
}
}
}
示例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)
})
}
示例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)
})
}
示例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())
})
示例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)
}
示例8: isDirectory
async isDirectory() {
const info = await stat(this.path)
if (!info.isDirectory()) {
throw new Error(`Path ${this.path} is not a file`)
}
}
示例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))
}
示例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')
})