added fs-extra to have ensure-dir for non existing dirs

This commit is contained in:
Manfred Knobloch 2019-06-03 09:42:45 +02:00
parent aafa528f03
commit da5ed78558
9 changed files with 54 additions and 805 deletions

View File

@ -7,7 +7,8 @@
*/
const puppeteer = require('puppeteer');
const fs = require("fs")
const fs_bare = require("fs") // required for fs-extra
const fs = require("fs-extra")
const path = require("path")
const start_dir = process.cwd()
const start_file = path.join(start_dir,"lib","index.html")
@ -39,18 +40,24 @@ async function makeScreenshot(href){
page.once("load",logPageEvent)
await page.goto(href)
href = href.replace("file:///","")
const fname = path.parse(href).name
let fpath
if (fname != "index"){
image_url = href.replace(fname + ".html" ,"thumbnails/" + fname + ".png")
fpath = href.replace(fname + ".html", "thumbnails")
}
else{
image_url = href.replace(fname + ".html" ,"thumbnail.png")
fpath = href.replace(fname + ".html", "")
}
image_url = image_url.replace("file:///","")
// image_url = image_url.replace("file:///","")
// fpath = fpath.replace("file:///","")
page.removeAllListeners()
fs.ensureDir(fpath)
await page.screenshot({path: image_url});
await browser.close();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 103 KiB

845
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
"gulp-uglify": "^3.0.2"
},
"dependencies": {
"fs-extra": "^8.0.1",
"gsap": "^2.1.3",
"hammerjs": "^2.0.8",
"optimal-select": "^4.0.1",