Skip to content

Commit

Permalink
use getPaths() helpers, and check schema in case of DB
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidprice committed May 26, 2020
1 parent b9b8375 commit 986a5c6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/cli/src/commands/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ export const builder = {
export const handler = async ({ app = ['db', 'api', 'web'] }) => {
// For Windows: Replaces ` ` with `\ `. Damn, there has got to be a better
// way to sanitize paths?!
// We use BASE_DIR when we need to effectively set the working dir
const BASE_DIR = getPaths().base.replace(' ', '\\ ')
const API_DIR = path.join(BASE_DIR, 'api')
const WEB_DIR = path.join(BASE_DIR, 'web')
// For validation, e.g. dirExists?, we use these
const API_DIR = getPaths().api.base
const WEB_DIR = getPaths().web.base
const PRISMA_SCHEMA = getPaths().api.dbSchema

const jobs = {
api: {
name: 'api',
command: `cd ${API_DIR} && yarn dev-server`,
command: `cd ${path.join(BASE_DIR, 'api')} && yarn dev-server`,
prefixColor: 'cyan',
runWhen: () => fs.existsSync(API_DIR),
},
Expand All @@ -33,7 +36,7 @@ export const handler = async ({ app = ['db', 'api', 'web'] }) => {
'api'
)} && yarn prisma generate --watch`,
prefixColor: 'magenta',
runWhen: () => fs.existsSync(API_DIR),
runWhen: () => fs.existsSync(PRISMA_SCHEMA),
},
web: {
name: 'web',
Expand Down

0 comments on commit 986a5c6

Please sign in to comment.