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 dev server run error when path contains spaces #609

Merged
merged 3 commits into from
May 27, 2020
Merged
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
28 changes: 15 additions & 13 deletions packages/cli/src/commands/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,38 @@ 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?!
const BASE_DIR = getPaths().base.replace(' ', '\\ ')
const API_DIR = path.join(BASE_DIR, 'api')
const WEB_DIR = path.join(BASE_DIR, 'web')
// We use BASE_DIR when we need to effectively set the working dir
const BASE_DIR = getPaths().base
// For validation, e.g. dirExists?, we use these
// note: getPaths().web|api.base returns undefined on Windows
const API_DIR_SRC = getPaths().api.src
const WEB_DIR_SRC = getPaths().web.src
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),
runWhen: () => fs.existsSync(API_DIR_SRC),
},
db: {
name: ' db', // prefixed with ` ` to match output indentation.
command: `cd ${path.join(
command: `cd "${path.join(
BASE_DIR,
'api'
)} && yarn prisma generate --watch`,
)}" && yarn prisma generate --watch`,
prefixColor: 'magenta',
runWhen: () => fs.existsSync(API_DIR),
runWhen: () => fs.existsSync(PRISMA_SCHEMA),
},
web: {
name: 'web',
command: `cd ${path.join(
command: `cd "${path.join(
BASE_DIR,
'web'
)} && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js`,
)}" && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js`,
prefixColor: 'blue',
runWhen: () => fs.existsSync(WEB_DIR),
runWhen: () => fs.existsSync(WEB_DIR_SRC),
},
}

Expand Down