Why and how to use afterwatch

NoxArt edited this page Sep 4, 2012 · 3 revisions

Why?

Afterwatch can be used for example for files that are compiled (let's say .less => .css, CSS or JS minification etc.) to be uploading automatically when changed after saving.

How?

Using settings property after_save_watch

Following settings are required:

  • upload_on_save = true
  • upload_delay > 0
    (needs to be long enough for the compilation to complete, in future there maybe separate timer)

What to enter to the entry? On the main level it is a list, values wrapped in [ ].
Example: ["foo","bar"]

This list should consist of lists.
Example: [ ["foo","bar"],[1,2,3] ]

These nested lists should contain 2 values:

  1. relative path (to the folder where your ftpsync.settings file is) to a folder where are watched files (those can be in its subfolders)
  2. filename pattern, decription here

The process then happens as follows (example):

  1. Made some changes to a .less file
  2. Hit save
  3. Files matching the after_save_watch gets indexed
  4. Waits for delay
  5. Uploads file
  6. Files matching the after_save_watch gets indexed again
  7. Compares indexes, filters out changed files
  8. Uploads changed files

Example project:
/home/NoxArt/projects/myWebsite
./ftpsync.settings
./styles/styles.less
./public/css/styles.css
./public/css/styles.min.css
etc.

"default": {
    "upload_on_save": true,
    "upload_delay": 3,
    "after_save_watch": [ [ "public/css", "*.css" ] ]
}