Skip to content

Commit

Permalink
working using puppeteer's downloaded chrome. need to fix the zip down…
Browse files Browse the repository at this point in the history
…loader
  • Loading branch information
matthewmueller committed Dec 3, 2017
1 parent c86a853 commit c65f619
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
21 changes: 10 additions & 11 deletions cmd/golly/golly.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"strings"
"syscall"

"github.com/matthewmueller/golly/internal/chrome/downloader"
"github.com/matthewmueller/golly/internal/compiler/util"

kingpin "gopkg.in/alecthomas/kingpin.v2"
Expand Down Expand Up @@ -82,20 +81,20 @@ func run(ctx context.Context) error {
}
filePath := path.Join(cwd, *runFile)

root, err := util.GollyPath()
if err != nil {
return errors.Wrapf(err, "error getting root path")
}
// root, err := util.GollyPath()
// if err != nil {
// return errors.Wrapf(err, "error getting root path")
// }

chromePath, err := downloader.Find(path.Join(root, "chrome"))
if err != nil {
return errors.Wrapf(err, "unable to get chrome path")
}
log.Infof("chromepath=%s", chromePath)
// chromePath, err := downloader.Find(path.Join(root, "chrome"))
// if err != nil {
// return errors.Wrapf(err, "unable to get chrome path")
// }
log.Infof("chromepath=%s", "./node_modules/puppeteer/.local-chromium/mac-515411/chrome-mac/Chromium.app/Contents/MacOS/Chromium")
// return errors.New("the Google Chrome path needs to be set")

result, err := api.Run(ctx, &api.RunSettings{
ChromePath: chromePath,
ChromePath: "./node_modules/puppeteer/.local-chromium/mac-515411/chrome-mac/Chromium.app/Contents/MacOS/Chromium",
FilePath: filePath,
})
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://news.ycombinator.com', { waitUntil: 'networkidle2' });
await page.pdf({ path: 'hn.pdf', format: 'A4' });

await browser.close();
})();
4 changes: 3 additions & 1 deletion internal/chrome/chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ var defaultFlags = []string{
"--disable-translate",
"--metrics-recording-only",
"--no-first-run",
"--remote-debugging-port=0",
"--safebrowsing-disable-auto-update",

"--enable-automation",
Expand Down Expand Up @@ -92,6 +91,9 @@ func New(parent context.Context, settings *Settings) (*Chrome, error) {
tmp := os.TempDir()
flags = append(flags, "--user-data-dir="+path.Join(tmp))

// remote debugging port
flags = append(flags, "--remote-debugging-port="+addr.Port())

// create the command
cmd := exec.CommandContext(ctx, settings.ExecutablePath, flags...)

Expand Down

0 comments on commit c65f619

Please sign in to comment.