forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use the project's babel config
- Loading branch information
1 parent
321b7fb
commit d593b5d
Showing
1 changed file
with
15 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |