fix(vhd-cli/repl): various fixes
This commit is contained in:
parent
312b33ae85
commit
8150d3110c
@ -1,18 +1,20 @@
|
||||
import { asCallback, fromCallback, fromEvent } from 'promise-toolbox'
|
||||
import { getHandler } from '@xen-orchestra/fs'
|
||||
import { resolve } from 'path'
|
||||
import { relative } from 'path'
|
||||
import { start as createRepl } from 'repl'
|
||||
import * as Vhd from 'vhd-lib'
|
||||
import Vhd, * as vhdLib from 'vhd-lib'
|
||||
|
||||
export default async args => {
|
||||
const handler = getHandler({ url: 'file://' + process.cwd() })
|
||||
const cwd = process.cwd()
|
||||
const handler = getHandler({ url: 'file://' + cwd })
|
||||
await handler.sync()
|
||||
try {
|
||||
const repl = createRepl({
|
||||
prompt: 'vhd> ',
|
||||
})
|
||||
Object.assign(repl.context, Vhd)
|
||||
repl.context.open = path => new Vhd.Vhd(handler, resolve(path))
|
||||
Object.assign(repl.context, vhdLib)
|
||||
repl.context.handler = handler
|
||||
repl.context.open = path => new Vhd(handler, relative(cwd, path))
|
||||
|
||||
// Make the REPL waits for promise completion.
|
||||
repl.eval = (evaluate => (cmd, context, filename, cb) => {
|
||||
|
Loading…
Reference in New Issue
Block a user