UNPKG

draig-car

Version:

Database REST API interactive generator CLI and REPL OpenAPI3 based JS generator with interactive ORM/ODM REPL

24 lines (21 loc) 589 B
const util = require('util') const chalk = require('chalk') const u = require('../util') const c = require('./common') module.exports.cdAction = function(name) { let ctx = this.context if (!name) { if (!ctx.apiPath.length) console.log('You are already at the root!') else ctx.apiPath.pop() } let [value, hashKey, path] = c.apiValue(ctx, name) if ( typeof value !== 'undefined' && util.isObject(eval('ctx.api' + hashKey)) ) { ctx.apiPath = path u.setPrompt(ctx) } else console.log(chalk`Path {yellow ${name}} does not exist or not an object`) this.displayPrompt() }