本文整理汇总了TypeScript中fs-extra-p.symlink函数的典型用法代码示例。如果您正苦于以下问题:TypeScript symlink函数的具体用法?TypeScript symlink怎么用?TypeScript symlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了symlink函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("postpone symlink", async () => {
const tmpDir = new TmpDir()
const source = await tmpDir.getTempFile("src")
const aSourceFile = path.join(source, "z", "Z")
const bSourceFileLink = path.join(source, "B")
await outputFile(aSourceFile, "test")
await symlink(aSourceFile, bSourceFileLink)
const dest = await tmpDir.getTempFile("dest")
await copyDir(source, dest)
await tmpDir.cleanup()
})
示例2: createFiles
async function createFiles(appDir: string) {
await Promise.all([
outputFile(path.join(appDir, "assets", "file"), "data"),
outputFile(path.join(appDir, "b2", "file"), "data"),
outputFile(path.join(appDir, "do-not-unpack-dir", "file.json"), "{}")
.then(() => writeFile(path.join(appDir, "do-not-unpack-dir", "must-be-not-unpacked"), "{}"))
])
const dir = path.join(appDir, "do-not-unpack-dir", "dir-2", "dir-3", "dir-3")
await mkdirs(dir)
await writeFile(path.join(dir, "file-in-asar"), "{}")
await symlink(path.join(appDir, "assets", "file"), path.join(appDir, "assets", "file-symlink"))
}
示例3: 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)
})
}
示例4: 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)
})
}
示例5: 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
const args = ["publish-s3", "--bucket", this.getBucketName(), "--key", target, "--file", task.file]
this.configureS3Options(args)
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
}
// https://github.com/aws/aws-sdk-go/issues/279
this.createProgressBar(fileName, -1)
// 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) => {
executeAppBuilder(args, process => {
onCancel(() => {
process.kill("SIGINT")
})
})
.then(() => {
try {
log.debug({provider: this.providerName, file: fileName, bucket: this.getBucketName()}, "uploaded")
}
finally {
resolve()
}
})
.catch(reject)
})
}
示例6: symlink
projectDirCreated: async projectDir => {
await symlink(path.join(getFixtureDir(), "pkg-scripts"), path.join(projectDir, "build", "pkg-scripts"))
},
示例7: symlink
BluebirdPromise.map(links, it => symlink(it.link, it.file), CONCURRENCY)
示例8: getTempFile
projectDirCreated: async projectDir => {
const tempDir = getTempFile()
await outputFile(path.join(tempDir, "foo"), "data")
await symlink(tempDir, path.join(projectDir, "o-dir"))
},
示例9: symlink
projectDirCreated: projectDir => {
return symlink(path.join(projectDir, "index.js"), path.join(projectDir, "foo.js"))
},