Skip to content

Commit 4821601

Browse files
committed
cleanups
1 parent 71b5a29 commit 4821601

2 files changed

Lines changed: 8 additions & 30 deletions

File tree

packages/dynamic-worker-bundler/src/installer.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ interface InstallOptions {
4141
* Registry URL (default: https://registry.npmjs.org)
4242
*/
4343
registry?: string;
44-
45-
/**
46-
* Called when a package is being installed
47-
*/
48-
onProgress?: (message: string) => void;
4944
}
5045

5146
interface InstallResult {
@@ -79,7 +74,7 @@ export async function installDependencies(
7974
files: Files,
8075
options: InstallOptions = {}
8176
): Promise<InstallResult> {
82-
const { dev = false, registry = NPM_REGISTRY, onProgress } = options;
77+
const { dev = false, registry = NPM_REGISTRY } = options;
8378

8479
const result: InstallResult = {
8580
files: { ...files },
@@ -119,15 +114,7 @@ export async function installDependencies(
119114
// Install all dependencies in parallel
120115
await Promise.all(
121116
Object.entries(depsToInstall).map(([name, versionRange]) =>
122-
installPackage(
123-
name,
124-
versionRange,
125-
result,
126-
installedPackages,
127-
inProgress,
128-
registry,
129-
onProgress
130-
)
117+
installPackage(name, versionRange, result, installedPackages, inProgress, registry)
131118
)
132119
);
133120

@@ -143,8 +130,7 @@ async function installPackage(
143130
result: InstallResult,
144131
installedPackages: Map<string, string>,
145132
inProgress: Map<string, Promise<void>>,
146-
registry: string,
147-
onProgress?: (message: string) => void
133+
registry: string
148134
): Promise<void> {
149135
// Skip if already installed
150136
if (installedPackages.has(name)) {
@@ -193,15 +179,7 @@ async function installPackage(
193179
const deps = versionMetadata.dependencies ?? {};
194180
await Promise.all(
195181
Object.entries(deps).map(([depName, depVersion]) =>
196-
installPackage(
197-
depName,
198-
depVersion,
199-
result,
200-
installedPackages,
201-
inProgress,
202-
registry,
203-
onProgress
204-
)
182+
installPackage(depName, depVersion, result, installedPackages, inProgress, registry)
205183
)
206184
);
207185
} catch (error) {

packages/tests/src/installer.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
12
import {
23
hasDependencies,
34
installDependencies,
45
} from '../../dynamic-worker-bundler/src/installer.js';
5-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
66

77
/**
88
* Create a minimal tar archive with the given files.
@@ -35,7 +35,7 @@ function createTarball(files: Record<string, string>): Uint8Array {
3535

3636
// Size (124-135) - octal, 11 chars + null
3737
const sizeOctal = contentBytes.length.toString(8).padStart(11, '0');
38-
header.set(encoder.encode(sizeOctal + '\0'), 124);
38+
header.set(encoder.encode(`${sizeOctal}\0`), 124);
3939

4040
// Mtime (136-147) - "00000000000\0"
4141
header.set(encoder.encode('00000000000\0'), 136);
@@ -49,10 +49,10 @@ function createTarball(files: Record<string, string>): Uint8Array {
4949
// Calculate checksum (sum of all bytes, treating checksum field as spaces)
5050
let checksum = 0;
5151
for (let i = 0; i < 512; i++) {
52-
checksum += header[i]!;
52+
checksum += header[i] ?? 0;
5353
}
5454
const checksumOctal = checksum.toString(8).padStart(6, '0');
55-
header.set(encoder.encode(checksumOctal + '\0 '), 148);
55+
header.set(encoder.encode(`${checksumOctal}\0 `), 148);
5656

5757
blocks.push(header);
5858

0 commit comments

Comments
 (0)