Skip to content

Commit 66a18c2

Browse files
authored
Merge pull request #11 from JuliaPluto/upgrade-node-18
2 parents 8d9eb6d + 3ace873 commit 66a18c2

File tree

9 files changed

+1118
-316
lines changed

9 files changed

+1118
-316
lines changed

.github/workflows/Test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ on:
1414
jobs:
1515
test:
1616
runs-on: ${{ matrix.os }}
17+
timeout-minutes: 20
18+
1719
strategy:
20+
fail-fast: false
1821
matrix:
1922
julia-version: ["1.6", "1"]
2023
os: [ubuntu-latest, windows-latest, macOS-latest]

Project.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ version = "0.1.4"
77
DefaultApplication = "3f0dd361-4fe0-5fc6-8523-80b14ec94d85"
88
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
99
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
10-
NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
10+
NodeJS_18_jll = "c1e1d063-8311-5f52-a749-c7b05e91ae37"
1111
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
1212

1313
[compat]
14-
julia = "1.6"
14+
DefaultApplication = "1"
1515
JSON = "0.20, 0.21"
16-
NodeJS = "1.3.0"
16+
NodeJS_18_jll = "18"
1717
Pluto = "0.16, 0.17, 0.18, 0.19"
18-
DefaultApplication = "1"
18+
julia = "1.6"
1919

2020
[extras]
2121
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

deps/build.jl

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import NodeJS
2-
npm = NodeJS.npm_cmd()
1+
import NodeJS_18_jll: npm
2+
3+
@assert isfile(npm)
4+
5+
6+
if Sys.iswindows()
7+
@warn "Windows might not be supported because of https://github.com/JuliaPackaging/Yggdrasil/issues/8095"
8+
end
9+
310
node_root = normpath(joinpath(@__DIR__, "../node"))
411
run(`$npm --version`)
512
println(run(`$npm --prefix=$node_root --scripts-prepend-node-path=true install $node_root`))

node/bin.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const exp = require("./export")
2-
const path = require("path")
3-
const fileUrl = require("file-url")
1+
import { pdf } from "./export.js"
2+
3+
import path from "path"
4+
import fileUrl from "file-url"
45

56
const fileInput = process.argv[2]
67
const fileOutput = process.argv[3]
@@ -15,11 +16,9 @@ if (!fileOutput) {
1516
process.exit(1)
1617
}
1718

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

22-
await exp.pdf(exportUrl, pdf_path, options)
22+
await pdf(exportUrl, pdf_path, options)
2323

24-
process.exit()
25-
})()
24+
process.exit()

node/export.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const p = require("puppeteer")
2-
const chalk = require("chalk")
1+
import p from "puppeteer"
2+
import chalk from "chalk"
33

44
function sleep(time) {
55
return new Promise((resolve, reject) => {
@@ -9,7 +9,7 @@ function sleep(time) {
99
})
1010
}
1111

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

4646
console.log("Exporting as pdf...")
4747
await page.pdf({
48-
path: output,
48+
path: pdf_path,
4949
...options,
5050
})
5151

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

5656
await browser.close()
5757
}
58-
59-
module.exports = { pdf }

0 commit comments

Comments
 (0)