Skip to content

Commit

Permalink
fix: ignore dotfiles in watcher (#1183)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>

closes #731
  • Loading branch information
SpaceK33z committed Jul 7, 2020
1 parent 47b0911 commit eb54c3c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/watcher/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function createWatcher(options: Options): Promise<Watcher> {
})

const watcher = Chok.watch([options.sourceRoot, ...pluginWatchContributions], {
ignored: ['./node_modules', './.*'],
ignored: ['./node_modules', /(^|[\/\\])\../],
ignoreInitial: true,
cwd: options.cwd, // prevent globbed files and required files from being watched twice,
})
Expand Down
38 changes: 33 additions & 5 deletions test/__helpers/e2e/kitchen-sink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { introspectionQuery } from 'graphql'
import { ConnectableObservable, Subscription } from 'rxjs'
import { refCount } from 'rxjs/operators'
import { ConnectableObservable, Subscription, timer } from 'rxjs'
import { refCount, takeUntil } from 'rxjs/operators'
import { createE2EContext, E2EContext } from '../../../src/lib/e2e-testing'
import { rootLogger } from '../../../src/lib/nexus-logger'
import { bufferOutput, takeUntilServerListening } from './utils'
Expand Down Expand Up @@ -130,15 +130,40 @@ export async function e2eKitchenSink(app: E2EContext) {
// so use `toContaine` instead of `toEqual`
expect(result.trim()).toContain('nexus@0.0.0-local')

//-------------------------------------------------
log.warn('run dev & test watcher settings')

proc = app.nexus(['dev'])
sub = proc.connect()
await proc.pipe(takeUntilServerListening).toPromise()

const pendingOutput = proc.pipe(bufferOutput, takeUntil(timer(5000))).toPromise()

// file events we should NOT see
app.fs.write('api/.foo.ts', 'ignoreme')
// app.fs.write('api/.next/foo.ts', 'ignoreme')
// app.fs.append('api/.foo.ts', ' updated')

// file events we should see
// app.fs.write('api/foo2.ts', 'seeme')
// app.fs.write('api/next/foo.ts', 'seeme')
// app.fs.append('api/foo.ts', ' updated')

output = (await pendingOutput) ?? ''
// todo leverage json logging to do structured asserts
// on macOS undefined, on linux ".\n", ... so we use a match instead of rigid equal check
expect(output).not.toMatch(/restarting|api\/\.foo\.ts/)
sub.unsubscribe()

//-------------------------------------------------
log.warn('run dev & query graphql api')

await buildApp()
await devAndBuildApp()

log.warn('Build and dev again without an app.ts entrypoint')
await app.fs.removeAsync('./api/app.ts')

await buildApp()
await devAndBuildApp()

//-------------------------------------------------
log.warn('create plugin')
Expand Down Expand Up @@ -223,7 +248,10 @@ export async function e2eKitchenSink(app: E2EContext) {
expect(output).toContain('build.onStart hook from foobar')
expect(output).toContain('success')

async function buildApp() {
/**
* run nexus dev & nexus build, along with a few checks within
*/
async function devAndBuildApp() {
proc = app.nexus(['dev'])
sub = proc.connect()

Expand Down

0 comments on commit eb54c3c

Please sign in to comment.