Ai
39 Star 483 Fork 264

CcSimple/electron-hiprint

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rename.js 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
Xavier 提交于 2025-06-19 20:04 +08:00 . Create release.yml
"use strict";
const path = require("path");
const fs = require("fs");
class ReName {
constructor() {
this.basePath = path.normalize(__dirname + "/..");
this.dirs = path.join(this.basePath, "/out/");
}
/**
* 格式化参数
*/
formatArgvs() {
let argv = {};
for (let i = 0; i < process.argv.length; i++) {
const tmpArgv = process.argv[i];
if (tmpArgv.indexOf("--") !== -1) {
let key = tmpArgv.substring(2);
let val = process.argv[i + 1];
argv[key] = val;
}
}
return argv;
}
rename(args) {
let that = this;
const pkgPath = path.join(that.basePath, "/package.json");
let pkg = JSON.parse(fs.readFileSync(pkgPath));
let version = pkg.version;
let productName = pkg.build.productName;
let fileName = `${productName}-${version}`;
let extList = [".exe", ".dmg", ".tar.xz", ".deb"];
extList.forEach((e) => {
let file = path.join(that.dirs, `${fileName}${e}`);
let nFile = path.join(
that.dirs,
`${productName}_${args["tag"]}-${version}${e}`,
);
if (fs.existsSync(file)) {
console.log("exist ", file);
console.log("rename ", nFile);
fs.renameSync(file, nFile);
}
});
}
}
const r = new ReName();
let argvs = r.formatArgvs();
console.log("[electron] [rename] argvs:", argvs);
r.rename(argvs);
module.exports = ReName;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/CcSimple/electron-hiprint.git
git@gitee.com:CcSimple/electron-hiprint.git
CcSimple
electron-hiprint
electron-hiprint
master

搜索帮助