Skip to content

Commit

Permalink
Fixed JavaScript documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavoja committed Apr 6, 2016
1 parent bf09de8 commit 00696f3
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,35 @@ aemsync -t http://admin:admin@localhost:4502,http://admin:admin@localhost:4503 -

JavaScript
```JavaScript
// Import aemsync.
const aemsync = require('aemsync')

// Set up the environment.
let workingDir = '~/workspace/my_project'
let targets = [
'http://admin:admin@localhost:4502',
'http://admin:admin@localhost:4503'
]
let exclude = '**/*.orig' // Skip merge files.
let pushInterval = 300

new aemsync.Watcher(workingDir, exclude, () => {
new aemsync.Pusher(targets, pushInterval, (err, host) => {
if (err) {
return console.log(`Error when pushing package to ${host}.`, err)
}
console.log(`Package pushed to ${host}.`)
})
let onPushEnd = (err, host) => {
if (err) {
return console.log(`Error when pushing package to ${host}.`, err)
}
console.log(`Package pushed to ${host}.`)
};

// Create Pusher and Watcher.
let pusher = new Pusher(targets, pushInterval, onPushEnd)
let watcher = new Watcher()

// Initialize queue processing.
pusher.start()

// Watch over workingDir.
watcher.watch(workingDir, exclude, (localPath) => {
// Add item to Pusher's queue when a change is detected.
pusher.addItem(localPath)
})
```

Expand Down

0 comments on commit 00696f3

Please sign in to comment.