Skip to content

Commit 9b17f4c

Browse files
committed
fix buildtime
1 parent 5e95cb5 commit 9b17f4c

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/package.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ type NativeUploadConfig = {
5050
) => string | number | undefined;
5151
};
5252

53+
export function normalizeUploadBuildTime(value: unknown): string {
54+
return String(value);
55+
}
56+
5357
function ensureFileByExt(
5458
filePath: string | undefined,
5559
extension: NativeUploadConfig['extension'] | '.aab',
@@ -116,11 +120,12 @@ async function uploadNativePackage(
116120
const normalizedBuildTime = config.normalizeBuildTime
117121
? config.normalizeBuildTime(buildTime)
118122
: buildTime;
123+
const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
119124

120125
const { id } = await post(`/app/${appId}/package/create`, {
121126
name: versionName,
122127
hash,
123-
buildTime: normalizedBuildTime,
128+
buildTime: uploadBuildTime,
124129
deps: depVersions,
125130
commit: await getCommitInfo(),
126131
});
@@ -129,7 +134,7 @@ async function uploadNativePackage(
129134
t(config.successKey, {
130135
id,
131136
version: versionName,
132-
buildTime: normalizedBuildTime,
137+
buildTime: uploadBuildTime,
133138
}),
134139
);
135140
}

tests/package-buildtime.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expect, test } from 'bun:test';
2+
import { normalizeUploadBuildTime } from '../src/package';
3+
4+
describe('package buildTime normalization', () => {
5+
test('converts number to string', () => {
6+
expect(normalizeUploadBuildTime(29538230)).toBe('29538230');
7+
expect(normalizeUploadBuildTime(0)).toBe('0');
8+
});
9+
10+
test('keeps string value', () => {
11+
expect(normalizeUploadBuildTime('29538230')).toBe('29538230');
12+
expect(normalizeUploadBuildTime(' 29538230 ')).toBe(' 29538230 ');
13+
});
14+
15+
test('always returns a string for any input', () => {
16+
expect(normalizeUploadBuildTime(undefined)).toBe('undefined');
17+
expect(normalizeUploadBuildTime(null)).toBe('null');
18+
expect(normalizeUploadBuildTime(Number.NaN)).toBe('NaN');
19+
expect(normalizeUploadBuildTime(Number.POSITIVE_INFINITY)).toBe('Infinity');
20+
expect(normalizeUploadBuildTime(Number.NEGATIVE_INFINITY)).toBe(
21+
'-Infinity',
22+
);
23+
});
24+
});

0 commit comments

Comments
 (0)