vite-plugin-auto-zip
Advanced tools
Comparing version 1.1.0 to 1.1.1
import * as path from 'node:path'; | ||
import {resolve} from 'node:path'; | ||
import { resolve } from 'node:path'; | ||
import JSZip from 'jszip'; | ||
@@ -7,3 +7,3 @@ import * as fs from 'node:fs'; | ||
function makeZip(config) { | ||
const {outPath: distPath, outName: fileName} = config; | ||
const { outPath: distPath, outName: fileName } = config; | ||
const zip = new JSZip(); | ||
@@ -14,13 +14,14 @@ const readDir = function (zipInstance, dirPath) { | ||
.forEach(fileName => { | ||
const fillPath = path.join(dirPath, "./", fileName); | ||
const file = fs.statSync(fillPath); | ||
// 如果是文件夹的话需要递归遍历下面的子文件 | ||
if (file.isDirectory()) { | ||
const dirZip = zipInstance.folder(fileName); | ||
readDir(dirZip, fillPath); | ||
} else { | ||
// 读取每个文件为buffer存到zip中 | ||
zip.file(fileName, fs.readFileSync(fillPath)); | ||
} | ||
}); | ||
const fillPath = path.join(dirPath, "./", fileName); | ||
const file = fs.statSync(fillPath); | ||
// 如果是文件夹的话需要递归遍历下面的子文件 | ||
if (file.isDirectory()) { | ||
const dirZip = zipInstance.folder(fileName); | ||
readDir(dirZip, fillPath); | ||
} | ||
else { | ||
// 读取每个文件为buffer存到zip中 | ||
zip.file(fileName, fs.readFileSync(fillPath)); | ||
} | ||
}); | ||
}; | ||
@@ -53,3 +54,3 @@ const removeExistedZip = () => { | ||
function AutoZip(folderPath, outPath = './dist', outName = 'dist.zip') { | ||
const options = {folderPath, outPath, outName}; | ||
const options = { folderPath, outPath, outName }; | ||
return { | ||
@@ -83,2 +84,2 @@ name: 'vite-plugin-auto-zip', | ||
export {AutoZip as default, zip}; | ||
export { AutoZip as default, zip }; |
{ | ||
"name": "vite-plugin-auto-zip", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "provide a vite plugin then zip your file after compile done", | ||
@@ -16,2 +16,3 @@ "main": "dist/vite-plugin-auto-zip.umd.js", | ||
"build:types": "rimraf -rf ./types && mkdir ./types && tsc -p ./tsconfig.json", | ||
"publish:npm": "yarn run build && npm publish", | ||
"test": "node test.js" | ||
@@ -18,0 +19,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4693
3
78