Skip to content

Commit

Permalink
Moved import of open to top to make clear 3rd-party dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Feb 4, 2025
1 parent fd754f3 commit d9364bd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions utils/preview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/usr/bin/env node

require('child_process').exec('http-server').stdout.on('data', async data => {
console.log(data)
if (data.includes('Starting up http-server')) // preview once (on 1st stdout msg)
(await import('open')).default(`http://localhost:8080${ process.argv.includes('--debug') ? '?debug=all' : '' }`)
})
(async () => {
const open = (await import('open')).default

require('child_process').exec('http-server').stdout.on('data', async data => {
console.log(data)
if (data.includes('Starting up http-server')) // preview once (on 1st stdout msg)
open(`http://localhost:8080${process.argv.includes('--debug') ? '?debug=all' : ''}`)
})

})()

0 comments on commit d9364bd

Please sign in to comment.