Skip to content

Commit 77dd2cd

Browse files
committed
Fix format
1 parent 0c040e7 commit 77dd2cd

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

bin/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function toFile(isDir, extn, files, dirs, useCRC32, startsWithDot)
9999
}
100100

101101
const npfiles = [[
102-
name__,
102+
'',
103103
files[0] ? files[0][1] : null
104104
]];
105105
const checksum = int32(crc32.str(JSON.stringify(

bin/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,22 @@ function findEmptyDirs(dir) {
458458
const delta = (await decompressFromBase64(filePath)).replaceAll("/", path.sep);
459459

460460
let fullPath;
461+
const dot = (startsWithDot ? '.' : '');
462+
let ext = '';
461463
if (typeof current === "undefined") {
462464
fullPath = path.resolve(output[0], delta);
463465
} else {
464466
fullPath = path.resolve(path.dirname(current), delta);
465467
}
466468
if (!isDir) {
467-
fullPath = output[0] + (startsWithDot ? '.' : '') + decompressFromBase64(extn);
469+
ext = await decompressFromBase64(extn);
470+
fullPath = output[0] + dot + ext;
468471
}
469-
current = checkPath(fullPath);
472+
473+
const isRootFile = (
474+
files.length === 1 && filePath === '' && !isDir
475+
);
476+
if (!isRootFile) current = checkPath(fullPath);
470477

471478
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
472479
fs.writeFileSync(fullPath, await decompressFromBase64(content), { encoding: "utf8" });

0 commit comments

Comments
 (0)