Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dev sync #1290

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1347,5 +1347,5 @@ Here's how to set up a dev env to hack on Roosevelt:
- If you do not want to sync these directories automatically, then run the `dev_sync.sh` script. To do that:
- Install [fswatch](https://github.com/emcrisostomo/fswatch) and [rsync](https://en.wikipedia.org/wiki/Rsync) and ensure they are in your PATH.
- Set a `DEST_DIR` environment variable: `export DEST_DIR=/path/to/your/roosevelt/app`
- Run the script: `sh dev_sync.sh`
- Or in one command: `export DEST_DIR=/path/to/your/roosevelt/app && sh dev_sync.sh`
- Run the script: `node dev_sync.js`
- Or in one command: `export DEST_DIR=/path/to/your/roosevelt/app && node dev_sync.js`
51 changes: 51 additions & 0 deletions dev_sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const Logger = require('roosevelt-logger')
this.logger = new Logger()
const fs = require('fs')
const SRC_DIR = __dirname
const DEST_DIR = process.env.DEST_DIR

try {
if (DEST_DIR === '') {
this.logger.error('ERROR: DEST_DIR is an empty variable')
} else if (DEST_DIR === SRC_DIR) {
this.logger.error('ERROR: DEST_DIR is pointing to the same path as SRC_DIR ')
} else {
if (fs.existsSync(`${DEST_DIR}/node_modules/roosevelt/`)) {
this.logger.info('💭', 'We are in a Roosevelt app ...')
fsWatch()
} else {
this.logger.info('')
this.logger.warn('Make sure the above directories are correct or this could delete unwanted files!')
this.logger.info('💭', 'We are not in a Roosevelt app ...')
this.logger.info('')
fsWatch()
}
}
} catch (err) { console.log(err) }

function fsWatch () {
const Logger = require('roosevelt-logger')
this.logger = new Logger()
const { execSync } = require('child_process')

this.logger.info('💭', 'Roosevelt fswatch rsync tool running...')
this.logger.info('')
this.logger.info('💭', `Now watching: ${SRC_DIR}`)
this.logger.info('💭', `Will copy to: ${DEST_DIR}`)
this.logger.info('')

execSync(`fswatch -0 ${SRC_DIR} | while read -d "" event
do
rsync -avz --delete --exclude=.DS_Store ${SRC_DIR}/ ${DEST_DIR}/node_modules/roosevelt/
done`, (error, stdout, stderr) => {
if (error) {
console.error(`error: ${error.message}`)
return
}
if (stderr) {
console.error(`stderr: ${stderr}`)
return
}
console.log(`stdout:\n${stdout}`)
})
}
16 changes: 0 additions & 16 deletions dev_sync.sh

This file was deleted.