fix(session): accept safe numeric job-count overrides
The command promises any positive safe integer, but its additional decimal-spelling regex rejected valid expert overrides such as 1e2 and +1. Let Number parse the supplied value and retain the positive safe-integer check. This preserves the CPU-based default cap while allowing equivalent numeric spellings and larger explicit values.
This commit is contained in:
1 parent
0dd9a282b8
commit
33d93ab155
2 files changed
+4
-4
No files matched your search
@@ -365,10 +365,10 @@ describe('one-time V4 migration command', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('accepts an explicit job count above the default cap', async () => {
|
||||
const result = await run('--sessions-dir', temporaryRoot(), '--jobs', '32')
|
||||
it.each(['32', '1e2', '+1', '01', ' 1'])('accepts positive safe-integer --jobs %s', async (jobs) => {
|
||||
const result = await run('--sessions-dir', temporaryRoot(), '--jobs', jobs)
|
||||
expect(result.status, result.stdout + result.stderr).toBe(0)
|
||||
expect(result.stdout).toContain('Session jobs: 32')
|
||||
expect(result.stdout).toContain(`Session jobs: ${Number(jobs)}`)
|
||||
expect(result.stdout).toContain('converted=0, already-V4=0, failed=0, skipped=0')
|
||||
expect(result.summary).toMatchObject({
|
||||
inputCount: 0,
|
||||
|
||||
@@ -289,7 +289,7 @@ if (process.argv[1] !== undefined && realpathSync(process.argv[1]) === realpathS
|
||||
if (values.help) console.log(usage)
|
||||
else {
|
||||
const jobs = values.jobs === undefined ? Math.min(availableParallelism(), 16) : Number(values.jobs)
|
||||
if (!Number.isSafeInteger(jobs) || jobs < 1 || (values.jobs !== undefined && !/^[1-9]\d*$/u.test(values.jobs))) {
|
||||
if (!Number.isSafeInteger(jobs) || jobs < 1) {
|
||||
throw new Error('--jobs must be a positive safe integer')
|
||||
}
|
||||
process.exitCode = await migrate(resolve(values['sessions-dir'] ?? join(homedir(), '.dsh', 'sessions')), jobs)
|
||||
|
||||
Reference in new issue
Block a user