Skip to content

Commit

Permalink
feat: use the project's babel config
Browse files Browse the repository at this point in the history
  • Loading branch information
redwoodjsbot committed Dec 8, 2020
1 parent 321b7fb commit d593b5d
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions packages/cli/src/commands/console.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import path from 'path'
import repl from 'repl'

import babelRequireHook from '@babel/register'

import { getPaths } from 'src/lib'

/**
* Console is less technical and more Railsy
*/
export const command = 'console'
/**
* @todo
* Appropriate alias?
*/
export const aliases = ['c']
export const description = 'Launch an interactive Redwood shell (experimental)'

/**
* @todo
* Should we make this more console related?
* I.e. does using the word REPL here contradict our efforts to be less technical?
*/
export const description = 'Start the Redwood REPL'
const paths = getPaths().api

const mapDBToContext = (ctx) => {
const { db } = require(path.join(getPaths().api.lib, 'db'))
const { db } = require(path.join(paths.lib, 'db'))
ctx.db = db
}

export const handler = () => {
// Transpile on the fly
require('@babel/register')
babelRequireHook({
extends: path.join(paths.base, '.babelrc.js'),
extensions: ['.js', '.ts'],
only: [paths.base],
ignore: ['node_modules'],
cache: false,
})

const r = repl.start()
// Just make the user's db (i.e. Prisma Client) available

// Make the project's db (i.e. Prisma Client) available
mapDBToContext(r.context)
}

0 comments on commit d593b5d

Please sign in to comment.