Skip to content

Instantly share code, notes, and snippets.

@katapad
Created May 10, 2013 04:42
Show Gist options
  • Save katapad/5552420 to your computer and use it in GitHub Desktop.
Save katapad/5552420 to your computer and use it in GitHub Desktop.
Gruntで更新のあったファイルだけFTPする
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-ftp-deploy'
ftpSettings =
auth:
host: "hogehoge.com"
port: 21
authKey: "hogehogekey"
src: "www"
dest: "/public_html/dest"
exclusions: ['**/.DS_Store', '**/*.*']
grunt.initConfig
watch:
ftp:
files: [ 'www/**/*' ]
tasks: ['ftp-deploy:changed']
options:
nospawn: true
'ftp-deploy':
changed:
# auth: '<%= ftp-deploy.build.auth %>'
auth: ftpSettings.auth
src: ftpSettings.src
dest: ftpSettings.dest
exclusions: ftpSettings.exclusions
grunt.registerTask 'w', ['watch:ftp']
grunt.event.on "watch", (action, filepath) ->
if action != 'changed'
return
target = '!' + filepath
exclusions = ftpSettings.exclusions.concat()
exclusions.push(target)
grunt.config.set 'ftp-deploy:changed:exclusions', exclusions
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment