Skip to content

Commit 2e05c4e

Browse files
committed
test
1 parent a8e0583 commit 2e05c4e

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

bin/index.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,12 @@ const instance = windows ? new JSSC() : {
385385
if (path.parse(input[0]).name != extname) extn = extname;
386386
}
387387

388+
let total = 0;
389+
let all = 0;
388390
if (windows) {
389391
WinUIWait = winUIWait('Compressing "' + path.parse(inp).name + '"...');
390392
instance.events.onCompressProgress = (percentage) => {
391-
WinUIWait.stdin.write(percentage + "\n");
393+
WinUIWait.stdin.write((total + percentage / all) + "\n");
392394
};
393395
}
394396

@@ -417,7 +419,15 @@ const instance = windows ? new JSSC() : {
417419
}
418420

419421
const files = [];
420-
for (const file of input.sort((a,b)=>a.localeCompare(b))) {
422+
const inputFiles = input.sort((a,b)=>a.localeCompare(b));
423+
all += inputFiles.length * 2;
424+
const dirs = [];
425+
const inputDirs = findEmptyDirs(inp);
426+
all += inputDirs.length;
427+
const includeExtn = extn != '';
428+
if (includeExtn) all += 1;
429+
430+
for (const file of inputFiles) {
421431
const current = p(file);
422432

423433
files.push([
@@ -428,21 +438,22 @@ const instance = windows ? new JSSC() : {
428438
)).replace(/=+$/, ''),
429439
Math.floor(fs.statSync(file).mtimeMs / 1000)
430440
]);
441+
total += 2;
431442
}
432-
const dirs = [];
433-
for (const dir of findEmptyDirs(inp)) {
443+
for (const dir of inputDirs) {
434444
const current = p(dir);
435445
dirs.push((await instance.compressToBase64(current, config)).replace(/=+$/, ''));
446+
total += 1;
436447
}
437448

438449
const startsWithDot = extn[0] == '.';
439450
fs.writeFileSync(output[0] + (
440451
addFormat ? format : ''
441452
), await toFile(
442453
isDir,
443-
extn == '' ? null : (await instance.compressToBase64(
454+
includeExtn ? (await instance.compressToBase64(
444455
startsWithDot ? extn.slice(1) : extn, config
445-
)).replace(/=+$/, ''),
456+
)).replace(/=+$/, '') : null,
446457
files,
447458
dirs,
448459
checksum,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strc",
3-
"version": "2.1.1-d",
3+
"version": "2.1.1-e",
44
"description": "JavaScript String Compressor - lossless string compression algorithm",
55
"main": "dist/jssc.cjs",
66
"repository": {

0 commit comments

Comments
 (0)