fix(jar): fix empty jar
This commit is contained in:
parent
feaf34c124
commit
2d05521789
@ -48,7 +48,7 @@ export async function jarStream({ groupId, artifactId, version, asyncPathGenerat
|
||||
for await (const entry of asyncPathGeneratorFn()) {
|
||||
if ("buffer" in entry) {
|
||||
zipFile.addBuffer(entry.buffer, entry.zipPath);
|
||||
} else if ("fsPath" in entry && entry.fsPath.endsWith(sep)) {
|
||||
} else if ("fsPath" in entry && !entry.fsPath.endsWith(sep)) {
|
||||
zipFile.addFile(entry.fsPath, entry.zipPath);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { readdir } from "fs/promises";
|
||||
import { resolve } from "path";
|
||||
import { resolve, sep } from "path";
|
||||
|
||||
/**
|
||||
* Asynchronously and recursively walk a directory tree, yielding every file and directory
|
||||
* found
|
||||
* found. Directory paths will _always_ end with a path separator.
|
||||
*
|
||||
* @param root the starting directory
|
||||
* @returns AsyncGenerator
|
||||
@ -12,8 +12,8 @@ export default async function* walk(root: string): AsyncGenerator<string, void,
|
||||
for (const entry of await readdir(root, { withFileTypes: true })) {
|
||||
const absolutePath = resolve(root, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
yield absolutePath;
|
||||
yield absolutePath.endsWith(sep) ? absolutePath : (absolutePath + sep);
|
||||
yield* walk(absolutePath);
|
||||
} else yield absolutePath;
|
||||
} else yield absolutePath.endsWith(sep) ? absolutePath.substring(0, absolutePath.length-1) : absolutePath;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user