带有多个目的地的grunt ftp_push

grunt ftp_push with more than one destination

本文关键字:grunt ftp push 目的地      更新时间:2024-04-19

我正在使用grunt-ftp-push将文件上传到服务器。

我正在尝试注册两个不同的任务——BuildPushDevBuildPush,所以我尝试了这个:

   ftp_push: {
        dev:{
            your_target: {
                options: {
                    username: "xxx",
                    password: "yyy",
                    host: "server.com",
                    dest: '/site/wwwroot/dev/assets/'
                },
                files: [
                    {
                        expand: true,
                        cwd: 'dist/assets',                            
                    }
                ]
            }
        },
        prod: {
            your_target: {
                 options: {
                    username: "xxx",
                    password: "yyy",
                    host: "server.com",
                    dest: '/site/wwwroot/dev/assets/'                     
                },
                files: [
                    {
                        expand: true,
                        cwd: 'dist/assets',                            
                    }
                ]
            }
        }
    }
grunt.registerTask('buildPush', [
    'build',
    'ftp_push:prod'
]);
grunt.registerTask('buildPushDev', [
    'build',
    'ftp_push:dev'
]);

但它不起作用:我得到了You did not specify all the requirements错误。

我做错了什么?或者我可以用什么替代方法在这里注册不同的任务?

您的目标定义是重复的-不需要your_target密钥。devprod您的目标。

只需取下它并"拉动"其余部分:

ftp_push: {
  dev:{
    options: {
      username: "xxx",
      password: "yyy",
      host: "server.com",
      dest: '/site/wwwroot/dev/assets/'
    },
    files: [
      {
        expand: true,
        cwd: 'dist/assets',                            
      }
    ]
  },
  prod: {
    options: {
      username: "xxx",
      password: "yyy",
      host: "server.com",
      dest: '/site/wwwroot/dev/assets/'                     
    },
    files: [
      {
        expand: true,
        cwd: 'dist/assets',                            
      }
    ]
  }
}