Skip to content

Commit f168fa6

Browse files
committed
fix: better dev scripts runner
1 parent 44cb10a commit f168fa6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

scripts/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ function log(message: string) {
1515
export async function run(name: string, ...steps: Step[]) {
1616
const { execSync } = await import('child_process');
1717

18+
const runOne = process.argv[2];
19+
if (runOne) {
20+
const match = steps.find((s) => `${name}/${s.name}` === runOne);
21+
if (!match) {
22+
console.error(`x No step found with name "${runOne}"`);
23+
process.exit(1);
24+
}
25+
26+
steps = [match];
27+
}
28+
29+
const start = process.hrtime();
1830
for (const step of steps) {
1931
if (!step.condition()) {
2032
log(`- Skipping step "${name}/${step.name}"...`);
@@ -29,4 +41,9 @@ export async function run(name: string, ...steps: Step[]) {
2941
process.exit(1);
3042
}
3143
}
44+
45+
const diff = process.hrtime(start);
46+
const time = diff[0] * 1e9 + diff[1];
47+
const timeStr = time > 1e9 ? `${(time / 1e9).toFixed(2)}s` : `${(time / 1e6).toFixed(2)}ms`;
48+
log(`✓ Steps in "${name}" completed in ${timeStr}.`);
3249
}

0 commit comments

Comments
 (0)