Skip to content

Commit 9926072

Browse files
committed
refactor: getMutoolPath → defaultMutool
1 parent 4e0253d commit 9926072

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ Type: `object`
121121

122122
Request headers that will be passed to fetch/prerender process.
123123

124-
##### mutoolPath
124+
##### mutool
125125

126-
Type: `function`
126+
Type: `function`|`boolean`<br>
127+
Default: `source code`
128+
129+
It returns a function that receives that executes [mutool](https://mupdf.com/) binary for turning PDF files into HTML markup.
127130

128-
It returns the path for [mutool](https://mupdf.com/) binary, used for turning PDF files into HTML markup.
131+
It can explicitly disabled passing `false`.
129132

130133
##### prerender
131134

benchmark/mupdf.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict'
22

3-
const { defaultMutoolPath: getMutoolPath } = require('../src/index')
43
const { readFile, readdir } = require('fs/promises')
5-
const $ = require('tinyspawn')
4+
const { defaultMutool } = require('../src/index')
65
const path = require('path')
76

87
const OUTPUT = path.join(__dirname, 'output.pdf')
@@ -67,7 +66,7 @@ class Benchmark {
6766
}
6867

6968
const main = async () => {
70-
const mutoolPath = getMutoolPath()
69+
const mutool = defaultMutool()
7170

7271
const fixtures = await readdir(path.join(__dirname, 'fixtures'))
7372

@@ -81,11 +80,11 @@ const main = async () => {
8180
}
8281
})
8382
.add('write in memory', async () => {
84-
const result = await $(`${mutoolPath} draw -q -F html ${filepath}`)
83+
const result = await mutool(filepath)
8584
return result.stdout
8685
})
8786
.add('write in file, read async', async () => {
88-
await $(`${mutoolPath} draw -q -F html -o ${OUTPUT} ${filepath}`)
87+
await mutool(`-o ${OUTPUT} ${filepath}`)
8988
return readFile(OUTPUT, 'utf-8')
9089
})
9190
.run()

test/pdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getBrowserless = initBrowserless(test)
1111
test('disable if `mutool` is not installed', async t => {
1212
const targetUrl = 'https://cdn.microlink.io/file-examples/sample.pdf'
1313
const { url, stats, html } = await getHTML(targetUrl, {
14-
mutoolPath: false,
14+
mutool: false,
1515
getBrowserless
1616
})
1717

0 commit comments

Comments
 (0)