use mkdtemp
This commit is contained in:
parent
ce0fc9001e
commit
445110c552
4 changed files with 9 additions and 5 deletions
7
main.ts
7
main.ts
|
@ -1,3 +1,6 @@
|
||||||
|
import fs from "node:fs/promises";
|
||||||
|
import os from "node:os";
|
||||||
|
import path from "node:path";
|
||||||
import util from "node:util";
|
import util from "node:util";
|
||||||
import { createBrowser } from "./browser";
|
import { createBrowser } from "./browser";
|
||||||
import { createDatabase } from "./database";
|
import { createDatabase } from "./database";
|
||||||
|
@ -174,7 +177,9 @@ const options = {
|
||||||
db,
|
db,
|
||||||
browser,
|
browser,
|
||||||
});
|
});
|
||||||
const dir = `${args.values["out-dir"]!}/${book.id}`;
|
const dir = await fs.mkdtemp(
|
||||||
|
path.join(os.tmpdir(), `gadl-${book.id}-`),
|
||||||
|
);
|
||||||
await platform.download(dir, book);
|
await platform.download(dir, book);
|
||||||
await library.archive(dir, book, {
|
await library.archive(dir, book, {
|
||||||
outDir: args.values["out-dir"]!,
|
outDir: args.values["out-dir"]!,
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fflate": "^0.8.1",
|
"fflate": "^0.8.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": "bin/run.js",
|
"bin": "bin/run.js",
|
||||||
|
|
|
@ -44,7 +44,6 @@ export function createPlatform(opts: {
|
||||||
...platform,
|
...platform,
|
||||||
|
|
||||||
async download(dir: string, book: Book): Promise<void> {
|
async download(dir: string, book: Book): Promise<void> {
|
||||||
await fs.mkdir(path.dirname(dir), { recursive: true });
|
|
||||||
await fs.mkdir(dir);
|
await fs.mkdir(dir);
|
||||||
|
|
||||||
const files: Array<() => Promise<Blob>> = await platform.getFiles(book);
|
const files: Array<() => Promise<Blob>> = await platform.getFiles(book);
|
||||||
|
|
Loading…
Add table
Reference in a new issue