本文整理汇总了TypeScript中tar.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _tar
function _tar(out: string, dir: string) {
return tar.create({
gzip: true,
strict: true,
portable: true,
cwd: dir,
file: out,
sync: true,
}, ['.']);
}
示例2: async
export const createArchive = async (fileName: string, folder: string, files: string[]): Promise<string> => {
try {
await tar.create(
{
cwd: folder,
file: fileName,
portable: true,
gzip: true
},
files
)
return fileName
} catch (err) {
throw new VError(err, `[Archive] Error creating archive "${fileName}"`)
}
}
示例3: zipFiles
async function zipFiles(modulePath, outPath) {
const packageJson = require(path.join(modulePath, 'package.json'))
outPath = outPath.replace(/%name%/gi, packageJson.name.replace(/[^\w-]/gi, '_'))
outPath = outPath.replace(/%version%/gi, packageJson.version.replace(/[^\w-]/gi, '_'))
if (!path.isAbsolute(outPath)) {
outPath = path.join(modulePath, outPath)
}
debug(`Writing to "${outPath}"`)
const files = glob.sync('**/*', {
cwd: modulePath,
nodir: true,
ignore: ['node_modules/**', 'src/**']
})
debug(`Zipping ${files.length} files...`)
await tar.create({ gzip: true, follow: true, file: outPath, portable: true }, files)
}
示例4: _tar
// This method mimics how npm pack tars packages.
function _tar(out: string, dir: string) {
// NOTE: node-tar does some Magic Stuff depending on prefixes for files
// specifically with @ signs, so we just neutralize that one
// and any such future "features" by prepending `./`
// Without this, the .tar file cannot be opened on Windows.
const files = _recursiveFileList(dir).map((f) => `./${f}`);
return tar.create({
gzip: true,
strict: true,
portable: true,
cwd: dir,
prefix: 'package/',
file: out,
sync: true,
// Provide a specific date in the 1980s for the benefit of zip,
// which is confounded by files dated at the Unix epoch 0.
mtime: new Date('1985-10-26T08:15:00.000Z'),
}, files);
}
示例5: tarFiles
function tarFiles(out: string, dir: string): Promise<void> {
// const files = fs.readdirSync(dir);
return tar.create({ gzip: true, strict: true, portable: true, cwd: dir, file: out }, ['.']);
}