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

fix: ignore dotfiles in watcher #1183

Merged
merged 7 commits into from
Jul 7, 2020
Merged
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
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