Skip to content

Commit

Permalink
Merge pull request #11 from JuliaPluto/upgrade-node-18
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Feb 12, 2024
2 parents 8d9eb6d + 3ace873 commit 66a18c2
Show file tree
Hide file tree
Showing 9 changed files with 1,118 additions and 316 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 20

strategy:
fail-fast: false
matrix:
julia-version: ["1.6", "1"]
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ version = "0.1.4"
DefaultApplication = "3f0dd361-4fe0-5fc6-8523-80b14ec94d85"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
NodeJS_18_jll = "c1e1d063-8311-5f52-a749-c7b05e91ae37"
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"

[compat]
julia = "1.6"
DefaultApplication = "1"
JSON = "0.20, 0.21"
NodeJS = "1.3.0"
NodeJS_18_jll = "18"
Pluto = "0.16, 0.17, 0.18, 0.19"
DefaultApplication = "1"
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
11 changes: 9 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import NodeJS
npm = NodeJS.npm_cmd()
import NodeJS_18_jll: npm

@assert isfile(npm)


if Sys.iswindows()
@warn "Windows might not be supported because of https://github.com/JuliaPackaging/Yggdrasil/issues/8095"
end

node_root = normpath(joinpath(@__DIR__, "../node"))
run(`$npm --version`)
println(run(`$npm --prefix=$node_root --scripts-prepend-node-path=true install $node_root`))
17 changes: 8 additions & 9 deletions node/bin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const exp = require("./export")
const path = require("path")
const fileUrl = require("file-url")
import { pdf } from "./export.js"

import path from "path"
import fileUrl from "file-url"

const fileInput = process.argv[2]
const fileOutput = process.argv[3]
Expand All @@ -15,11 +16,9 @@ if (!fileOutput) {
process.exit(1)
}

;(async () => {
const exportUrl = fileInput.startsWith("http://") || fileInput.startsWith("https://") ? fileInput : fileUrl(path.resolve(fileInput))
const pdf_path = path.resolve(fileOutput)
const exportUrl = fileInput.startsWith("http://") || fileInput.startsWith("https://") ? fileInput : fileUrl(path.resolve(fileInput))
const pdf_path = path.resolve(fileOutput)

await exp.pdf(exportUrl, pdf_path, options)
await pdf(exportUrl, pdf_path, options)

process.exit()
})()
process.exit()
10 changes: 4 additions & 6 deletions node/export.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const p = require("puppeteer")
const chalk = require("chalk")
import p from "puppeteer"
import chalk from "chalk"

function sleep(time) {
return new Promise((resolve, reject) => {
Expand All @@ -9,7 +9,7 @@ function sleep(time) {
})
}

async function pdf(url, output, options, beforeClose = async () => {}) {
export async function pdf(url, pdf_path, options, beforeClose = async () => {}) {
const browser = await p.launch()
console.log("Initiated headless browser")
const page = await browser.newPage()
Expand Down Expand Up @@ -45,7 +45,7 @@ async function pdf(url, output, options, beforeClose = async () => {}) {

console.log("Exporting as pdf...")
await page.pdf({
path: output,
path: pdf_path,
...options,
})

Expand All @@ -55,5 +55,3 @@ async function pdf(url, output, options, beforeClose = async () => {}) {

await browser.close()
}

module.exports = { pdf }
Loading

0 comments on commit 66a18c2

Please sign in to comment.