UNPKG

@molejs/mole-tools

Version:

Configuration and scripts for Mole App.

55 lines (49 loc) 1.82 kB
const shelljs = require('shelljs'); const path = require('path'); const fs = require('fs'); /** * 判断文件夹是否存在 */ function fsExistsSync(path) { try { fs.accessSync(path, fs.F_OK); } catch(e) { return false; } return true; } exports.publish = function({ repo_url, build_type, username, password, }) { // console.log("******************svn*********************") // console.log(username, password, repo_url, build_type); // console.log("******************svn*********************") //const svnWorkDir = 'mole-tools-svntmp/' + build_type; // 本地仓库地址 const svnWorkDir = '.mole-tools-tmp/svn/' + build_type; shelljs.rm('-rf', svnWorkDir); shelljs.mkdir('-p', svnWorkDir); shelljs.cd(svnWorkDir); shelljs.exec('svn checkout '+ repo_url + ' ../'+build_type +' --username '+ username + ' --password ' + password) shelljs.rm('-rf', ['./lib', './css', './script', './index.html', './icon', './wgt', './html', './image', './res', './modules', './config.xml', './public']) shelljs.exec('svn delete ./wgt'); shelljs.exec('svn delete ./icon'); shelljs.exec('svn delete ./index.html'); shelljs.exec('svn delete ./css'); shelljs.exec('svn delete ./lib'); shelljs.exec('svn delete ./html'); shelljs.exec('svn delete ./image'); shelljs.exec('svn delete ./res '); shelljs.exec('svn delete ./modules '); shelljs.exec('svn delete ./video '); shelljs.exec('svn delete ./lib '); shelljs.exec('svn delete ./config.xml'); shelljs.cp('-rf', ['../../../public', '../../../res', '../../../modules', '../../../config.xml'], './'); shelljs.exec('svn add . --no-ignore --force'); const publishUser = shelljs.exec('echo $USER'); shelljs.exec(`svn commit -m "auto commit ${build_type} by ${publishUser}"`); shelljs.cd('../../../'); }