svn-safe

1.0.0 • Public • Published

#引入svn-safe

$ npm install --save svn-safe

var svnSafe = require('svn-safe');

#提供给外部的方法

/**
 * 从svn上获取一个文件,直接暴漏到外部的方法
 * @param svnBase   svn目录
 * @param filepath  svn文件名
 * @param destPath  存放位置
 * @param version   svn版本号
 * @returns {*}
 */
module.exports.svnGetFile = function (svnBase, filepath, destPath, version)

/**
 * 将用户名&密码写入配置文件
 * @param results
 * @returns {*}
 */
module.exports.recordSvnConfig = function(results)

/**
 * 判断存储svn配置的文件是否存在
 * @returns {boolean}
 */
module.exports.svnConfigExits = function ()

#结合grunt-prompt插件,让用户输入自己的svn帐号

//在grunt.initConfig配置中增加prompt属性(当然需要先安装)
prompt: {
            target: {
                options: {
                    questions: [
                        {
                            config: 'svn.username', // arbitray name or config for any other grunt task
                            type: 'input', // list, checkbox, confirm, input, password
                            message: '输入你的svn用户名:',
                            default: 'value', // default value if nothing is entered
                            when: function (answers) {
                                return !( svnSafe.svnConfigExits() )
                            }
                        },
                        {
                            config: 'svn.password', // arbitray name or config for any other grunt task
                            type: 'password', // list, checkbox, confirm, input, password
                            message: '输入你的svn密码:',
                            default: 'value', // default value if nothing is entered
                            when: function (answers) {
                                return answers['svn.username'];
                            }
                        }
                    ],
                    then: function (results) {
                        if (results['svn.username'] && results['svn.password']){
                            svnSafe.recordSvnConfig(results);
                        }
                    }
                }
            }
        },

Readme

Keywords

Package Sidebar

Install

npm i svn-safe

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • changzhiwin