0.2.5 Update deps, add example and example repo directory to go with example
parent
233670ecbd
commit
0dd1fdd18b
|
@ -0,0 +1,24 @@
|
|||
import Watcher from '../src/watcher'
|
||||
import onDeath from 'ondeath'
|
||||
|
||||
(async () => {
|
||||
let options = {source:'./example/repo/**', ignored:['**/dontwatch.js'],ignoreList:['./example/repo/.gitignore']}
|
||||
// let options = {source:'./readme.md'}
|
||||
// let options = {source:'./example/*'}
|
||||
|
||||
let watcher = new Watcher(options)
|
||||
await watcher.start()
|
||||
|
||||
watcher.on('changed',
|
||||
(change) => {
|
||||
console.log(`======= file ${change.file} was ${change.type} ==========`)
|
||||
})
|
||||
|
||||
onDeath( () => {
|
||||
console.log('\nHe\'s dead Jim')
|
||||
watcher.remove()
|
||||
})
|
||||
|
||||
})().catch(err => {
|
||||
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
**/node_modules/**
|
|
@ -0,0 +1,5 @@
|
|||
tests/
|
||||
test/
|
||||
*.test.js
|
||||
testing/
|
||||
example/
|
|
@ -0,0 +1,3 @@
|
|||
this was modified some moreddddddd
|
||||
modified
|
||||
changes
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"ignore": ["example/repo/*"]
|
||||
}
|
17
package.json
17
package.json
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"name": "@uci-utils/watcher",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.5",
|
||||
"description": "File System Watcher Class that emits events",
|
||||
"main": "src/watcher.js",
|
||||
"scripts": {
|
||||
"example": "node -r esm ./example/example.js",
|
||||
"exampled": "UCI_ENV=dev UCI_LOG_LEVEL=debug ./node_modules/.bin/nodemon -r esm ./example/example.js",
|
||||
"test": "./node_modules/.bin/mocha -r esm --timeout 30000",
|
||||
"testd": "UCI_ENV=dev ./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha -r esm --timeout 30000' || exit 0",
|
||||
"testdd": "UCI_LOG_LEVEL='trace' npm run testd",
|
||||
|
@ -28,14 +30,15 @@
|
|||
},
|
||||
"homepage": "https://github.com/uCOMmandIt/uci-utils#readme",
|
||||
"dependencies": {
|
||||
"@uci-utils/logger": "0.0.13",
|
||||
"@uci-utils/read-lines": "^0.2.1",
|
||||
"chokidar": "^2.1.1"
|
||||
"@uci-utils/logger": "0.0.16",
|
||||
"@uci-utils/read-lines": "^0.2.2",
|
||||
"chokidar": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"esm": "^3.2.4",
|
||||
"mocha": "^5.2.0",
|
||||
"nodemon": "^1.18.10"
|
||||
"esm": "^3.2.25",
|
||||
"mocha": "^6.2.0",
|
||||
"nodemon": "^1.19.1",
|
||||
"ondeath": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
### File System Watcher Class
|
||||
#### a uCOMmandIt Utiltiy Function
|
||||
|
||||
Extends Choikar
|
||||
|
|
|
@ -14,7 +14,7 @@ const READY_TIMEOUT = 2000
|
|||
class Watcher extends Emitter {
|
||||
constructor(opts={}) {
|
||||
super()
|
||||
log = logger({ package:'@uci/sync', class:'Watcher', file:'src/watcher.js'})
|
||||
log = logger({ package:'@uci-utils/watcher', class:'Watcher', file:'src/watcher.js'})
|
||||
opts.unlinkDir = Object.hasOwnProperty(opts.unlinkDir) ? opts.unlinkDir : true
|
||||
this.opts = opts
|
||||
this._ignored = []
|
||||
|
|
|
@ -12,7 +12,6 @@ describe('Watcher Class Testing ',async ()=> {
|
|||
let watcher = new Watcher(options)
|
||||
await watcher.start()
|
||||
watcher.on('changed',
|
||||
// debounce(
|
||||
(change) => {
|
||||
console.log(`======= file ${change.file} was ${change.type} ==========`)
|
||||
}
|
||||
|
@ -21,15 +20,15 @@ describe('Watcher Class Testing ',async ()=> {
|
|||
})
|
||||
|
||||
|
||||
it('can watch for file delete' , async function () {
|
||||
// let [err,res] = await to(remote.exec('cd /opt && pwd'))
|
||||
// if (err) {
|
||||
// log.info('error running command aborting test', err)
|
||||
// return
|
||||
// }
|
||||
// log.info(`result of remote command ${res.command} => ${res.reply.toString().trim()}`)
|
||||
expect('test', 'test failed').to.equal('test')
|
||||
})
|
||||
// it('can watch for file delete' , async function () {
|
||||
// // let [err,res] = await to(remote.exec('cd /opt && pwd'))
|
||||
// // if (err) {
|
||||
// // log.info('error running command aborting test', err)
|
||||
// // return
|
||||
// // }
|
||||
// // log.info(`result of remote command ${res.command} => ${res.reply.toString().trim()}`)
|
||||
// expect('test', 'test failed').to.equal('test')
|
||||
// })
|
||||
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue