Skip to content

Commit

Permalink
Always use polling in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed Jan 14, 2017
1 parent b4eed5f commit 2ecb656
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/lib/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { logEmitted, logRemoved, logError } from './logger'

export function watch (
dirs: string[],
compilerOptions: ts.CompilerOptions = {}
compilerOptions: ts.CompilerOptions = {},
usePolling: boolean = false
): chokidar.FSWatcher {
const watcher = chokidar.watch(dirs)
const watcher = chokidar.watch(dirs, {
usePolling
})

const service = new LanguageService([], {
...compilerOptions,
Expand Down
10 changes: 3 additions & 7 deletions test/specs/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('watch', () => {

beforeEach(done => {
fs.mkdir(p('./'), () => {
watcher = watch([p('./')]).on('ready', done)
watcher = watch([p('./')], {}, true).on('ready', done)
})
})

Expand All @@ -39,7 +39,7 @@ describe('watch', () => {
watcher.on('change', once(() => {
test(p('test.vue.d.ts'), 'export declare const foo: number;')
done()
}, 1))
}))

fs.writeFile(p('test.vue'), vue('export const test: string = ""'))
})
Expand Down Expand Up @@ -71,14 +71,10 @@ describe('watch', () => {
})
})

function once (fn: () => void, skip: number = 0): (p: string) => void {
function once (fn: () => void): (p: string) => void {
let done = false
return path => {
if (!/\.vue.d.ts$/.test(path)) return
if (skip > 0) {
skip -= 1
return
}
if (done) return
fn()
done = true
Expand Down

0 comments on commit 2ecb656

Please sign in to comment.