修改自动推送git仓库
This commit is contained in:
+5
-10
@@ -7,7 +7,8 @@ const config = {
|
||||
repoUrl: 'http://git2.haodian.cn/lcc/pinan_dist.git', // 目标仓库地址
|
||||
branch: 'master', // 目标分支
|
||||
distPath: path.resolve(__dirname, './dist'), // 构建产物目录
|
||||
commitMessage: `Auto-deploy at ${new Date().toISOString()}` // 提交信息
|
||||
// commitMessage: `Auto-deploy at ${new Date().toISOString()}`
|
||||
commitMessage: `Auto-deploy at ${new Date().toLocaleString('sv-SE')}` // 提交信息
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -24,13 +25,8 @@ try {
|
||||
execSync('git init');
|
||||
execSync(`git remote add origin ${config.repoUrl}`);
|
||||
}
|
||||
|
||||
// 拉取最新代码
|
||||
execSync(`git pull origin ${config.branch} --rebase`, { stdio: 'ignore' });
|
||||
|
||||
// 添加所有文件
|
||||
execSync('git add .');
|
||||
|
||||
// 提交更改
|
||||
try {
|
||||
execSync(`git commit -m "${config.commitMessage}"`);
|
||||
@@ -38,13 +34,12 @@ try {
|
||||
console.log('没有需要提交的更改');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// 推送到目标仓库
|
||||
execSync(`git push origin ${config.branch}`);
|
||||
execSync(`git push -f origin ${config.branch}`);
|
||||
|
||||
console.log('部署成功!');
|
||||
console.log('推送仓库成功!');
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('部署失败:', error.message);
|
||||
console.error('推送仓库失败:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@
|
||||
"build:report": "vue-cli-service build --report",
|
||||
"lint": "vue-cli-service lint",
|
||||
"clean:lib": "rimraf node_modules",
|
||||
"build:deploy": "vue-cli-service build && node deploy.js"
|
||||
"build:deploy": "vue-cli-service build && node deploy.js",
|
||||
"deploy": "node deploy.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@amap/amap-jsapi-loader": "^1.0.1",
|
||||
|
||||
Reference in New Issue
Block a user