fix: 修复ZIP打包文件名前缀参数支持
This commit is contained in:
@@ -10,9 +10,10 @@ const execAsync = promisify(exec);
|
|||||||
* 使用系统命令创建ZIP(跨平台)
|
* 使用系统命令创建ZIP(跨平台)
|
||||||
* @param {string} sourceDir - 要压缩的目录路径
|
* @param {string} sourceDir - 要压缩的目录路径
|
||||||
* @param {string} outputDir - 压缩文件输出目录
|
* @param {string} outputDir - 压缩文件输出目录
|
||||||
|
* @param {string} zipPrefix - ZIP文件名前缀,默认 'mp-weixin'
|
||||||
* @returns {Promise<string>} - 压缩文件的路径
|
* @returns {Promise<string>} - 压缩文件的路径
|
||||||
*/
|
*/
|
||||||
async function createZipWithSystemCommand(sourceDir, outputDir) {
|
async function createZipWithSystemCommand(sourceDir, outputDir, zipPrefix = 'mp-weixin') {
|
||||||
// 检查源目录
|
// 检查源目录
|
||||||
if (!fs.existsSync(sourceDir)) {
|
if (!fs.existsSync(sourceDir)) {
|
||||||
throw new Error(`源目录不存在: ${sourceDir}`);
|
throw new Error(`源目录不存在: ${sourceDir}`);
|
||||||
@@ -30,7 +31,7 @@ async function createZipWithSystemCommand(sourceDir, outputDir) {
|
|||||||
// 生成文件名:mp-weixin-<日期时间>-<提交ID>.zip
|
// 生成文件名:mp-weixin-<日期时间>-<提交ID>.zip
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const dateString = `${now.getFullYear()}${String(now.getMonth()+1).padStart(2,'0')}${String(now.getDate()).padStart(2,'0')}-${String(now.getHours()).padStart(2,'0')}${String(now.getMinutes()).padStart(2,'0')}${String(now.getSeconds()).padStart(2,'0')}`;
|
const dateString = `${now.getFullYear()}${String(now.getMonth()+1).padStart(2,'0')}${String(now.getDate()).padStart(2,'0')}-${String(now.getHours()).padStart(2,'0')}${String(now.getMinutes()).padStart(2,'0')}${String(now.getSeconds()).padStart(2,'0')}`;
|
||||||
const zipFileName = `mp-weixin-v${dateString}-${commitId}.zip`;
|
const zipFileName = `${zipPrefix}-v${dateString}-${commitId}.zip`;
|
||||||
const zipFilePath = path.join(outputDir, zipFileName);
|
const zipFilePath = path.join(outputDir, zipFileName);
|
||||||
|
|
||||||
let command;
|
let command;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async function main() {
|
|||||||
const cwd = path.join(__dirname, '..');
|
const cwd = path.join(__dirname, '..');
|
||||||
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', '.mp-harmony');
|
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', '.mp-harmony');
|
||||||
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
||||||
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir);
|
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir, 'mp-harmony');
|
||||||
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
||||||
await openFileDirectory(zipFilePath);
|
await openFileDirectory(zipFilePath);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ async function main() {
|
|||||||
const cwd = path.join(__dirname, '..');
|
const cwd = path.join(__dirname, '..');
|
||||||
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin');
|
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin');
|
||||||
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
||||||
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir);
|
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir, 'mp-weixin');
|
||||||
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
||||||
await openFileDirectory(zipFilePath);
|
await openFileDirectory(zipFilePath);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user