Created
August 14, 2017 13:37
-
-
Save bidiu/38086dac295e7729184a9f517f534403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { execSync } = require('child_process'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const SVN_DIR_PATH = path.join(__dirname, '..', 'svn'); | |
if (!fs.existsSync(SVN_DIR_PATH)) { | |
fs.mkdirSync(SVN_DIR_PATH); | |
} | |
function execCmd(cmd, { fromDir = '.' } = {}) { | |
return execSync(cmd, { | |
cwd: fromDir, | |
stdio: 'inherit' | |
}); | |
} | |
/** | |
* In case of error, this function will throw an object, | |
* which is the result of child_process.spawnSync(). For | |
* more info see: | |
* | |
* https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_child_process_execsync_command_options | |
* | |
* @param {*} url url to checkout | |
* @param {*} savePath save path, relative to ${SVN_DIR_PATH} | |
* @param {*} noAuthCache | |
*/ | |
function checkout(url, savePath, noAuthCache = false) { | |
execCmd(`svn checkout ${url} ${savePath} ${noAuthCache ? '--no-auth-cache' : ''}`, { fromDir: SVN_DIR_PATH }); | |
} | |
exports.checkout = checkout; | |
exports.SVN_DIR_PATH = SVN_DIR_PATH; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment