Skip to content

Commit e6fb06a

Browse files
committed
Run CI sandbox with Bun
1 parent 7e0c1f4 commit e6fb06a

File tree

4 files changed

+51
-29
lines changed

4 files changed

+51
-29
lines changed

ci/.codesandbox/tasks.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"setupTasks": [
3+
{
4+
"name": "Install Bun",
5+
"command": "npm install --global bun"
6+
},
7+
{
8+
"name": "Install Dependencies",
9+
"command": "bun install"
10+
}
11+
],
12+
"tasks": {
13+
"build": {
14+
"name": "build",
15+
"command": "bun run build"
16+
},
17+
"dev": {
18+
"name": "dev",
19+
"command": "bun start",
20+
"runAtStart": true,
21+
"preview": {
22+
"port": 3000
23+
}
24+
}
25+
}
26+
}

ci/package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@
44
"description": "numeric-quantity Test Page",
55
"main": "index.html",
66
"scripts": {
7-
"start": "parcel index.html --open",
8-
"build": "parcel build index.html"
7+
"start": "bun index.html",
8+
"build": "bun build index.html"
99
},
1010
"dependencies": {
11-
"numeric-quantity": "^2.0.0",
12-
"parcel-bundler": "^1.12.5"
11+
"numeric-quantity": "^2.0.1"
1312
},
1413
"devDependencies": {
15-
"typescript": "^5.1.3"
16-
},
17-
"resolutions": {
18-
"@babel/preset-env": "7.13.8"
19-
},
20-
"keywords": []
14+
"typescript": "^5.8.3"
15+
}
2116
}

ci/src/index.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,21 @@ const strings = [
123123
'I',
124124
];
125125

126-
const app = document.getElementById('app')!;
126+
const tbodyInnerHTML = strings
127+
.map(str => {
128+
const nq = `${numericQuantity(str)}`;
129+
const nqa = `${numericQuantity(str, { allowTrailingInvalid: true })}`;
130+
const nqr = `${numericQuantity(str, { romanNumerals: true })}`;
131+
return `<tr><td>numericQuantity("${str}")</td><td>${nq}</td><td${nqa !== nq ? ' class="diff"' : ''}>${nqa}</td><td${nqr !== nq ? ' class="diff"' : ''}>${nqr}</td></tr>`;
132+
})
133+
.join('');
127134

128-
app.innerHTML = `<h1>numeric-quantity CI</h1>
135+
document.getElementById('app')!.innerHTML = `<h1>numeric-quantity CI</h1>
129136
<table>
130-
<thead><tr><th>Expression</th><th>Result</th></tr></thead>
137+
<thead><tr><th>Expression</th><th>Default</th><th>allowTrailingInvalid</th><th>romanNumerals</th></tr></thead>
138+
<tbody>${tbodyInnerHTML}</tbody>
131139
</table>`;
132140

133-
const table = document.querySelector('table')!;
134-
const tbody = document.createElement('tbody')!;
135-
136-
for (const s of strings) {
137-
const tr = document.createElement('tr');
138-
const result = numericQuantity(s, {
139-
romanNumerals: true,
140-
allowTrailingInvalid: true,
141-
});
142-
tr.innerHTML = `<td>numericQuantity("${s}")</td><td>${result}</td>`;
143-
tbody.appendChild(tr);
144-
}
145-
146-
table.appendChild(tbody);
141+
Object.defineProperty(globalThis, 'numericQuantity', {
142+
value: numericQuantity,
143+
});

ci/src/styles.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ td {
88
padding: 4px;
99
}
1010

11-
th:first-child,
12-
td:first-child {
11+
th:not(:last-child),
12+
td:not(:last-child) {
1313
border-right: 1px solid lightgray;
1414
}
15+
16+
.diff {
17+
background-color: color-mix(in srgb, rebeccapurple, transparent 90%);
18+
}

0 commit comments

Comments
 (0)