diff --git a/packages/vhd-cli/src/commands/repl.js b/packages/vhd-cli/src/commands/repl.js index f6818820e..91daaf9be 100644 --- a/packages/vhd-cli/src/commands/repl.js +++ b/packages/vhd-cli/src/commands/repl.js @@ -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) => {