Skip to content

Commit

Permalink
Merge branch 'commands-enhancements' of github.com:uqbar-project/woll…
Browse files Browse the repository at this point in the history
…ok-ts-cli into commands-enhancements
  • Loading branch information
fdodino committed Nov 8, 2023
2 parents 48a4b96 + 279e578 commit e3a5a8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/commands/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export default async function (autoImportPath: string | undefined, options: Opti
logger.info(`Initializing Wollok REPL ${autoImportPath ? `for file ${valueDescription(autoImportPath)} ` : ''}on ${valueDescription(options.project)}`)

let interpreter = await initializeInterpreter(autoImportPath, options)
const io: Server | undefined = options.noDiagram ? undefined : await initializeClient(options)
const _ = options.noDiagram ? undefined : await initializeClient(options)

Check warning on line 37 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L37

Added line #L37 was not covered by tests

const io = _?.io
const server = _?.server

Check warning on line 40 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L39-L40

Added lines #L39 - L40 were not covered by tests

const commandHandler = defineCommands(autoImportPath, options, () => {
io?.emit('updateDiagram', getDataDiagram(interpreter))

Check warning on line 43 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L43

Added line #L43 was not covered by tests
Expand Down Expand Up @@ -67,10 +70,11 @@ export default async function (autoImportPath: string | undefined, options: Opti
repl.prompt()
})

io?.on('connection', _socket => {
server?.addListener('listening', () => {

Check warning on line 73 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L73

Added line #L73 was not covered by tests
logger.info(successDescription('Dynamic diagram available at: ' + bold(`http://localhost:${options.port}`)))
repl.prompt()
})

io?.on('connection', socket => {

Check warning on line 78 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L78

Added line #L78 was not covered by tests
socket.emit('initDiagram', options)
socket.emit('updateDiagram', getDataDiagram(interpreter))
Expand Down Expand Up @@ -238,7 +242,7 @@ async function initializeClient(options: Options) {
express.static(publicPath('diagram'), { maxAge: '1d' }),
)
server.listen(parseInt(options.port), 'localhost')
return io
return { server, io }

Check warning on line 245 in src/commands/repl.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/repl.ts#L245

Added line #L245 was not covered by tests
}

function newImport(importNode: Import, environment: Environment) {
Expand Down
1 change: 1 addition & 0 deletions test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ describe('Test', () => {
expect(processExitSpy.callCount).to.equal(0)
expect(spyCalledWithSubstring(loggerInfoSpy, 'Running 2 tests')).to.be.true
expect(spyCalledWithSubstring(loggerInfoSpy, '2 passing')).to.be.true
expect(spyCalledWithSubstring(loggerInfoSpy, '0 failing')).to.be.false // old version
})

it('returns exit code 2 if one or more tests fail', async () => {
Expand Down

0 comments on commit e3a5a8d

Please sign in to comment.