Skip to content

Commit

Permalink
Merge pull request #137 from marp-team/change-watch-port-number
Browse files Browse the repository at this point in the history
Change port number for file watcher from 52000 to 37717
  • Loading branch information
yhatt authored Aug 23, 2019
2 parents 81ba8c0 + 0dacfc6 commit 0d06e89
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ports:
- port: 8080
onOpen: open-preview
- port: 52000
- port: 37717
onOpen: ignore
tasks:
- init: yarn install
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changed

- Reconnect to file watcher when disconnected from WebSocket server ([#130](https://github.com/marp-team/marp-cli/pull/130))
- Change port number for file watcher from 52000 to 37717 ([#135](https://github.com/marp-team/marp-cli/issues/135), [#137](https://github.com/marp-team/marp-cli/pull/137))

## v0.12.1 - 2019-07-13

Expand Down
2 changes: 1 addition & 1 deletion src/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class WatchNotifier {

async port() {
if (this.portNumber === undefined)
this.portNumber = await portfinder.getPortPromise({ port: 52000 })
this.portNumber = await portfinder.getPortPromise({ port: 37717 })

return this.portNumber
}
Expand Down
2 changes: 1 addition & 1 deletion test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('Converter', () => {

const { result } = await converter.convert(md, dummyFile)
expect(result).toContain(
`<script>window\.__marpCliWatchWS="ws://localhost:52000/${hash}";`
`<script>window\.__marpCliWatchWS="ws://localhost:37717/${hash}";`
)
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/templates/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Watch mode notifier on browser context', () => {
let server: Server

const createWSServer = async () => {
const port = await portfinder.getPortPromise({ port: 52000 })
const port = await portfinder.getPortPromise({ port: 37717 })

return new Promise<Server>((res, rej) => {
try {
Expand Down
14 changes: 7 additions & 7 deletions test/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,36 +165,36 @@ describe('WatchNotifier', () => {
expect(notifier).toBeInstanceOf(WatchNotifier))

describe('#port', () => {
it('finds available port from 52000', async () => {
it('finds available port from 37717', async () => {
const finderSpy = jest.spyOn(portfinder, 'getPortPromise')
const instance = new WatchNotifier()

expect(await instance.port()).toBe(52000)
expect(await instance.port()).toBe(37717)
expect(finderSpy).toHaveBeenCalledTimes(1)

// Return stored port number of instance when called twice
await instance.port()
expect(finderSpy).toHaveBeenCalledTimes(1)
})

context('when 52000 port is using for the other purpose', () => {
context('when 37717 port is using for the other purpose', () => {
let server: http.Server

beforeEach(
() => (server = http.createServer((_, res) => res.end()).listen(52000))
() => (server = http.createServer((_, res) => res.end()).listen(37717))
)
afterEach(() => server.close())

it('returns port number 52001', async () =>
expect(await new WatchNotifier().port()).toBe(52001))
it('returns port number 37718', async () =>
expect(await new WatchNotifier().port()).toBe(37718))
})
})

describe('#register', () => {
it('generates WebSocket URL from path string and add to listeners', async () => {
const instance = new WatchNotifier()
expect(await instance.register('test')).toBe(
`ws://localhost:52000/${testIdentifier}`
`ws://localhost:37717/${testIdentifier}`
)

const listenerSet = instance.listeners.get(testIdentifier)
Expand Down

0 comments on commit 0d06e89

Please sign in to comment.