UNPKG

1.82 kBJavaScriptView Raw
1const shelljs = require('shelljs');
2const path = require('path');
3const fs = require('fs');
4
5
6/**
7 * 判断文件夹是否存在
8 */
9function fsExistsSync(path) {
10 try {
11 fs.accessSync(path, fs.F_OK);
12 } catch(e) {
13 return false;
14 }
15 return true;
16}
17
18
19exports.publish = function({
20 repo_url,
21 build_type,
22 username,
23 password,
24}) {
25 // console.log("******************svn*********************")
26 // console.log(username, password, repo_url, build_type);
27 // console.log("******************svn*********************")
28 //const svnWorkDir = 'mole-tools-svntmp/' + build_type;
29 // 本地仓库地址
30 const svnWorkDir = '.mole-tools-tmp/svn/' + build_type;
31 shelljs.rm('-rf', svnWorkDir);
32
33 shelljs.mkdir('-p', svnWorkDir);
34 shelljs.cd(svnWorkDir);
35 shelljs.exec('svn checkout '+ repo_url + ' ../'+build_type +' --username '+ username + ' --password ' + password)
36
37 shelljs.rm('-rf', ['./lib', './css', './script', './index.html', './icon', './wgt', './html', './image', './res', './modules', './config.xml', './public'])
38 shelljs.exec('svn delete ./wgt');
39 shelljs.exec('svn delete ./icon');
40 shelljs.exec('svn delete ./index.html');
41 shelljs.exec('svn delete ./css');
42 shelljs.exec('svn delete ./lib');
43 shelljs.exec('svn delete ./html');
44 shelljs.exec('svn delete ./image');
45 shelljs.exec('svn delete ./res ');
46 shelljs.exec('svn delete ./modules ');
47 shelljs.exec('svn delete ./video ');
48 shelljs.exec('svn delete ./lib ');
49 shelljs.exec('svn delete ./config.xml');
50 shelljs.cp('-rf', ['../../../public', '../../../res', '../../../modules', '../../../config.xml'], './');
51 shelljs.exec('svn add . --no-ignore --force');
52 const publishUser = shelljs.exec('echo $USER');
53 shelljs.exec(`svn commit -m "auto commit ${build_type} by ${publishUser}"`);
54 shelljs.cd('../../../');
55}
\No newline at end of file