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 { asCallback, fromCallback, fromEvent } from 'promise-toolbox'
|
||||||
import { getHandler } from '@xen-orchestra/fs'
|
import { getHandler } from '@xen-orchestra/fs'
|
||||||
import { resolve } from 'path'
|
import { relative } from 'path'
|
||||||
import { start as createRepl } from 'repl'
|
import { start as createRepl } from 'repl'
|
||||||
import * as Vhd from 'vhd-lib'
|
import Vhd, * as vhdLib from 'vhd-lib'
|
||||||
|
|
||||||
export default async args => {
|
export default async args => {
|
||||||
const handler = getHandler({ url: 'file://' + process.cwd() })
|
const cwd = process.cwd()
|
||||||
|
const handler = getHandler({ url: 'file://' + cwd })
|
||||||
await handler.sync()
|
await handler.sync()
|
||||||
try {
|
try {
|
||||||
const repl = createRepl({
|
const repl = createRepl({
|
||||||
prompt: 'vhd> ',
|
prompt: 'vhd> ',
|
||||||
})
|
})
|
||||||
Object.assign(repl.context, Vhd)
|
Object.assign(repl.context, vhdLib)
|
||||||
repl.context.open = path => new Vhd.Vhd(handler, resolve(path))
|
repl.context.handler = handler
|
||||||
|
repl.context.open = path => new Vhd(handler, relative(cwd, path))
|
||||||
|
|
||||||
// Make the REPL waits for promise completion.
|
// Make the REPL waits for promise completion.
|
||||||
repl.eval = (evaluate => (cmd, context, filename, cb) => {
|
repl.eval = (evaluate => (cmd, context, filename, cb) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user