Skip to content

Commit

Permalink
Was able to have the script dev_sync.js run every 5 seconds after you…
Browse files Browse the repository at this point in the history
… run it the first time, so every 5 seconds it will copy the files to the destination folder. Also You must press Control + C to properly close it
  • Loading branch information
RailonA committed Aug 22, 2023
1 parent 7f7119e commit 092edea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,8 @@ Here's how to set up a dev env to hack on Roosevelt:
- Set a `DEST_DIR` environment variable: `export DEST_DIR=/path/to/your/roosevelt/app`
- Run the script: `node dev_sync.js`
- Or in one command: `export DEST_DIR=/path/to/your/roosevelt/app && node dev_sync.js`
- To end the script press: `control^ + C`
-For Windows
- Set a `DEST_DIR` environment variable: `$env:DEST_DIR="/path/to/your/roosevelt/app"`
- Run the script: `node dev_sync.js`
- Run the script: `node dev_sync.js`
- To end the script press: `control^ + C`
10 changes: 8 additions & 2 deletions dev_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ try {
this.logger.error('ERROR: DEST_DIR is pointing to the same path as SRC_DIR ')
} else {
if (fs.existsSync(rsvtConfig) || fs.existsSync(`${DEST_DIR}/roosevelt/`)) {
this.logger.info('')
this.logger.info('💭')
this.logger.info('💭', 'We are in a Roosevelt app ...')
fsWatch()
} else {
Expand Down Expand Up @@ -48,17 +50,21 @@ async function fsWatch () {
this.logger.info('💭', `Now watching: ${SRC_DIR}`)
this.logger.info('💭', `Will copy to: ${DEST_DIR}`)
this.logger.info('')
})

setInterval(function () {
rsync.execute(function (error, code, cmd) {
if (error) {
this.logger.error(`ERROR: ${error.message}`)
}
})
}, 5000)

process.on('SIGINT', function () {
console.log('')
console.log('')
console.log('💭')
console.log('💭 Closing rsync')
console.log('💭 Closing fswatch')

console.log('💭')
watcher.close()
process.exit()
Expand Down

0 comments on commit 092edea

Please sign in to comment.