Skip to content

Commit

Permalink
fix(api-dev): Ensure dist, types and db paths are ignored on windows (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 authored and peterp committed Sep 3, 2021
1 parent 4ba05f8 commit 96d4a5b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/api-server/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import chokidar from 'chokidar'
import dotenv from 'dotenv'
import { debounce } from 'lodash'

import { getPaths, buildApi, getConfig } from '@redwoodjs/internal'
import {
getPaths,
buildApi,
getConfig,
ensurePosixPath,
} from '@redwoodjs/internal'

const rwjsPaths = getPaths()

Expand Down Expand Up @@ -54,16 +59,23 @@ const delayRestartServer = debounce(
: 5
)

// NOTE: the file comes through as a unix path, even on windows
// So we need to convert the rwjsPaths

const IGNORED_API_PATHS = [
'api/dist', // use this, because using rwjsPaths.api.dist seems to not ignore on first build
rwjsPaths.api.types,
rwjsPaths.api.db,
].map((path) => ensurePosixPath(path))

chokidar
.watch(rwjsPaths.api.base, {
persistent: true,
ignoreInitial: true,
ignored: (file: string) => {
const x =
file.includes('node_modules') ||
file.includes(rwjsPaths.api.dist) ||
file.includes(rwjsPaths.api.types) ||
file.includes(rwjsPaths.api.db) ||
IGNORED_API_PATHS.some((ignoredPath) => file.includes(ignoredPath)) ||
[
'.DS_Store',
'.db',
Expand Down

0 comments on commit 96d4a5b

Please sign in to comment.