-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangfuxing
committed
Nov 6, 2024
1 parent
251423b
commit 57c542b
Showing
11 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { EventEmitter } from "node:events"; | ||
export { ensureDir, ensureFile } from "jsr:@std/[email protected]"; | ||
export { exists, ensureDir } from "jsr:@std/[email protected]"; | ||
export * as path from "jsr:@std/[email protected]"; | ||
export { Buffer, copy, readAll, writeAll } from "jsr:@std/[email protected]"; | ||
export { crc32, Crc32Stream } from "jsr:@deno-library/[email protected]"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Buffer, copy, ensureDir, path, ensureFile } from "../deps.ts"; | ||
import { Buffer, copy, ensureDir, exists, path } from "../deps.ts"; | ||
import type { compressInterface, uncompressInterface } from "../interface.ts"; | ||
import { Tar } from "jsr:@std/[email protected]/tar"; | ||
import { Untar } from "jsr:@std/[email protected]/untar"; | ||
|
@@ -14,7 +14,7 @@ export async function uncompress( | |
dest: string, | ||
options?: uncompressInterface, | ||
): Promise<void> { | ||
await ensureFile(src); | ||
await exists(src, { isFile: true }); | ||
using reader = await Deno.open(src, { read: true }); | ||
const untar = new Untar(reader); | ||
for await (const entry of untar) { | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import { | ||
assert, | ||
assertEquals, | ||
} from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { assert, assertEquals } from "jsr:@std/assert"; | ||
import { tar } from "../mod.ts"; | ||
|
||
Deno.test("tar.compress file", async () => { | ||
const src = "./test/tar/tar.txt"; | ||
const src = "./test/dir/root.txt"; | ||
const dest = "./test.tar"; | ||
try { | ||
await tar.compress(src, dest, { debug: true }); | ||
|
@@ -22,7 +19,7 @@ Deno.test("tar.compress file", async () => { | |
}); | ||
|
||
Deno.test("tar.compress folder", async () => { | ||
const src = "./test/tar"; | ||
const src = "./test/dir"; | ||
const dest = "./test.tar"; | ||
try { | ||
await tar.compress(src, dest, { debug: true }); | ||
|
@@ -49,7 +46,7 @@ Deno.test("tar.uncompress", async () => { | |
const landTxtSize = 5; | ||
const landTxtContent = "land\n"; | ||
try { | ||
await tar.uncompress(src, dest); | ||
await tar.uncompress(src, dest, { debug: true }); | ||
const stat = await Deno.lstat(landTxtPath); | ||
assertEquals(stat.size, landTxtSize); | ||
const buf = await Deno.readFile(landTxtPath); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { assert, assertEquals } from "jsr:@std/assert"; | ||
import { zip } from "../mod.ts"; | ||
|
||
Deno.test("zip.compress file", async () => { | ||
const src = "./test/dir/root.txt"; | ||
const dest = "./test.zip"; | ||
try { | ||
await zip.compress(src, dest, { debug: true }); | ||
const stat = await Deno.lstat(dest); | ||
assertEquals(stat.size, 255); | ||
await Deno.remove(dest); | ||
} catch (error) { | ||
console.error(error); | ||
assert(false); | ||
} | ||
}); | ||
|
||
Deno.test("zip.compress folder", async () => { | ||
const src = "./test/dir"; | ||
const dest = "./deno.zip"; | ||
try { | ||
await zip.compress(src, dest, { debug: true }); | ||
const stat = await Deno.lstat(dest); | ||
assertEquals(stat.size, 943); | ||
await Deno.remove(dest); | ||
} catch (error) { | ||
console.error(error); | ||
assert(false); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters