Grunt - Watch a file and SFTP when it's changed

泄露秘密 提交于 2019-11-30 20:07:00

I would like to confirm that the following grunt-ssh (https://github.com/andrewrjones/grunt-ssh) task config worked fine for me. Note that grunt accepts --verbose option which may help debug. Note that as of v0.6.2 grunt-ssh SFTP task did not seem to support sshconfig syntax, which was not very clear from the help page.

    sftpCredentials: grunt.file.readJSON('sftp-credentials.json'),
    sftp: {
        deploy: {
            files: {
                "./": "deploy/**"
            },
            options: {
                "path": "<%= sftpCredentials.path %>",
                "host": "<%= sftpCredentials.host %>",
                "username": "<%= sftpCredentials.username %>",
                "port": "<%= sftpCredentials.port %>",
                "password": "<%= sftpCredentials.password %>",
                "srcBasePath": "deploy/",
                "createDirectories": true
            }
        }
    }

I was trying to do something almost identical using grunt-sftp and ran into similar errors. The logging wasn't the greatest so I ended up using grunt-shell and just ran scp upon compilation:

watch: {
    tumblr: {
        files:['sass/*.scss', 'sass/*/*.scss'],
        tasks: [ 'compass:tumblr', 'shell:tumblr' ]
    }
},

shell: {
  tumblr: {
    command: 'scp -P 2222 -r stylesheets "myname@myserver.com:/var/www/foo/directory"'
  }
}

This worked like a charm.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!