Skip to content

Commit

Permalink
fix(openApp): Try alternate way of closing browser
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsonchuong committed Jan 9, 2019
1 parent 9a27209 commit 41bfeb9
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/* @flow */
import type { Tab } from 'puppet-strings'
import { promisify } from 'util'
import { openChrome, openTab, closeBrowser } from 'puppet-strings'
import Bundler from 'parcel-bundler'
import tempy from 'tempy'
import getPort from 'get-port'

const sleep = promisify(setTimeout)

export default async function(appPath: string): Promise<Tab> {
const bundler = new Bundler(appPath, {
watch: false,
Expand All @@ -25,13 +22,10 @@ export default async function(appPath: string): Promise<Tab> {

// Always true--to appease the type-checker
if (tab.puppeteer) {
tab.puppeteer.page.on('close', async () => {
// Allow enough time for Puppeteer to clean up before closing browser
await sleep(0)

closeBrowser(browser)
tab.puppeteer.page.close = async () => {
await closeBrowser(browser)
server.close()
})
}
}

return tab
Expand Down

0 comments on commit 41bfeb9

Please sign in to comment.