HJ_Client/extensions/svn/dist/svn.js
DESKTOP-15R5JU0\legu 62fef0360c init
2023-11-17 14:13:11 +08:00

79 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.svnCleanup = exports.svnRevert = exports.svnLog = exports.svnCommit = exports.svnUpdate = exports.isSvnWorkingCopy = exports.checkInstallSvn = void 0;
const child_process_1 = require("child_process");
/**是否安装了svn */
function checkInstallSvn() {
return new Promise(res => {
(0, child_process_1.exec)('svn --version --quiet', (error, stdout, stderr) => {
if (stdout) {
res(true);
}
else {
res(false);
}
});
});
}
exports.checkInstallSvn = checkInstallSvn;
/**是否是svn工作副本 */
function isSvnWorkingCopy() {
return new Promise(res => {
(0, child_process_1.exec)('svn info ' + Editor.Project.path, (error, stdout, stderr) => {
if (stdout) {
res(true);
}
else {
res(false);
}
});
});
}
exports.isSvnWorkingCopy = isSvnWorkingCopy;
async function checkSvnEnvironment(succCall) {
let cond1 = await checkInstallSvn();
let cond2 = await isSvnWorkingCopy();
if (!cond1) {
return Editor.Dialog.error('未安装svn或svn未添加环境变量');
}
if (!cond2) {
return Editor.Dialog.error('当前项目不是svn工作副本');
}
cond1 && cond2 && succCall();
}
function svnUpdate(path = '') {
console.log('svn更新路径', path);
checkSvnEnvironment(() => {
(0, child_process_1.exec)('TortoiseProc.exe /command:update /path:' + path);
});
}
exports.svnUpdate = svnUpdate;
function svnCommit(path = '') {
console.log('svn提交路径', path);
checkSvnEnvironment(() => {
(0, child_process_1.exec)('TortoiseProc.exe /command:commit /path:' + path);
});
}
exports.svnCommit = svnCommit;
function svnLog(path = '') {
console.log('svn日志路径', path);
checkSvnEnvironment(() => {
(0, child_process_1.exec)('TortoiseProc.exe /command:log /path:' + path);
});
}
exports.svnLog = svnLog;
function svnRevert(path = '') {
console.log('svn还原路径', path);
checkSvnEnvironment(() => {
(0, child_process_1.exec)('TortoiseProc.exe /command:revert /path:' + path);
});
}
exports.svnRevert = svnRevert;
function svnCleanup(path = '') {
console.log('svn清理路径', path);
checkSvnEnvironment(() => {
(0, child_process_1.exec)('TortoiseProc.exe /command:cleanup /path:' + path);
});
}
exports.svnCleanup = svnCleanup;