Methods
(async) autoDownloadFiles() → {Promise}
- Description:
自動定位chrome.exe,若無檔案則自動下載,回傳chrome.exe的絕對路徑
依序偵測當前工作路徑的chrome/與node_modules/w-html2png/chrome/,皆無chrome.exe時, 代表安裝時npm封鎖scripts致postinstall未執行,故自動調用downloadFiles重新下載
供w-html2png自身與其他依賴w-html2png的套件調用,無須各自實作偵測與下載邏輯
因免安裝chrome只能用於Windows作業系統,故調用前須自行檢核作業系統
- Source:
Example
import autoDownloadFiles from 'w-html2png/src/autoDownloadFiles.mjs'
async function test() {
//autoDownloadFiles, 無chrome.exe時自動下載, 下載失敗則reject
let { fpExe } = await autoDownloadFiles()
console.log('fpExe', fpExe)
// fpExe D:\xxx\node_modules\w-html2png\chrome\portable\App\Chrome-bin\138.0.7204.97\chrome.exe
}
test()
.catch((err) => {
console.log('catch', err)
})
Returns:
回傳Promise,resolve回傳執行檔路徑物件,內含fpExe為chrome.exe的絕對路徑字串,reject回傳錯誤訊息
- Type
- Promise