zoukankan      html  css  js  c++  java
  • GruntJs之FTP上传文件

    因为项目需要,又试了一下Grunt的FTP插件:grunt-ftpscript。以下步骤是基于上一篇博文的配置环境的:http://blog.csdn.net/puncha/article/details/10442147


    (一)安装

    1. C:Grunt>npm install grunt-ftpscript --save-dev
    2. C:Grunt>npm install matchdep --save
    装matchdep是为了能够通过一句命令,加载所有的Grunt插件,在下面的代码里面就能看到。

    (二)代码:

    这里我没有直接执行task,而是随后通过命令行执行的。


    Gruntfile.js:

    module.exports = function (grunt) {
        grunt.initConfig({
            ftpscript: {
                main: {
                    options: {
                        host: 'shacng109wqrh',
                        port: 21,
                        passive: true
                    },
                    files: [
                        { expand: true, cwd: 'filesToCopy', src: ['*'], dest: '/filesCopied/' }
                    ]
                }
            },
        });
    
        require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    };

    .ftppass: (因为我没设FTP密码,所以不能写password这个属性,不然会出现笨等待)

    {
      "shacng109wqrh" : {
        "username": "cer"
      }
    }

    (三)运行:

    C:Grunt>grunt ftpscript:main

    提示成功:

    Running "ftpscript:main" (ftpscript) task
    Connected to SHACNG109WQRH.ads.autodesk.com.
    220-FileZilla Server version 0.9.41 beta
    220-written by Tim Kosse (Tim.Kosse@gmx.de)
    >> 220 Please visit http://sourceforge.net/projects/filezilla/
    Interactive mode Off .
    Invalid command.
    >> 257 "/filesCopied" created successfully
    >> 226 Transfer OK
    ftp: 382 bytes sent in Seconds Kbytes/sec.
    0.00382000.00221 Goodbye
    
    Done, without errors.

    就这么简单~~~







  • 相关阅读:
    Python父类调用子类
    Python中for else注意事项
    JS Number类型数字位数及IEEE754标准
    cocos打包到ios与android上音频推荐
    JS学习之预解析(执行上下文)
    JS学习之函数的作用域
    JS学习之函数二
    JS学习之函数
    如何在subline中高亮显示.vue文件
    JS之正则
  • 原文地址:https://www.cnblogs.com/puncha/p/3876884.html
Copyright © 2011-2022 走看看