0.2.5 Update deps, add example and example repo directory to go with example

master
David Kebler 2019-08-10 21:21:33 -07:00
parent 233670ecbd
commit 0dd1fdd18b
10 changed files with 58 additions and 18 deletions

24
example/example.js Normal file
View File

@ -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)
})

1
example/repo/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
**/node_modules/**

5
example/repo/.npmignore Normal file
View File

@ -0,0 +1,5 @@
tests/
test/
*.test.js
testing/
example/

0
example/repo/deletethis Normal file
View File

View File

@ -0,0 +1,3 @@
this was modified some moreddddddd
modified
changes

3
nodemon.json Normal file
View File

@ -0,0 +1,3 @@
{
"ignore": ["example/repo/*"]
}

View File

@ -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"
}
}

View File

@ -1,2 +1,4 @@
### File System Watcher Class
#### a uCOMmandIt Utiltiy Function
Extends Choikar

View File

@ -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 = []

View File

@ -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')
// })
})