Skip to content

Commit 54f1376

Browse files
committed
Refactor generateDatetimeVersion to function declaration
1 parent fd9f942 commit 54f1376

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

scripts/generate-binary-package.mjs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ import { parseArgs } from '@socketsecurity/lib/argv/parse'
1212
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1313
const rootDir = path.join(__dirname, '..')
1414

15+
/**
16+
* Generates a datetime-based version string.
17+
*/
18+
function generateDatetimeVersion() {
19+
const now = new Date()
20+
const year = now.getFullYear()
21+
const month = String(now.getMonth() + 1).padStart(2, '0')
22+
const day = String(now.getDate()).padStart(2, '0')
23+
const hours = String(now.getHours()).padStart(2, '0')
24+
const minutes = String(now.getMinutes()).padStart(2, '0')
25+
const seconds = String(now.getSeconds()).padStart(2, '0')
26+
return `${year}.${month}.${day}.${hours}${minutes}${seconds}`
27+
}
28+
1529
const { values } = parseArgs({
1630
options: {
1731
platform: { type: 'string' },
@@ -39,18 +53,6 @@ if (!platform || !arch) {
3953
process.exit(1)
4054
}
4155

42-
// Generate datetime version if not provided
43-
const generateDatetimeVersion = () => {
44-
const now = new Date()
45-
const year = now.getFullYear()
46-
const month = String(now.getMonth() + 1).padStart(2, '0')
47-
const day = String(now.getDate()).padStart(2, '0')
48-
const hours = String(now.getHours()).padStart(2, '0')
49-
const minutes = String(now.getMinutes()).padStart(2, '0')
50-
const seconds = String(now.getSeconds()).padStart(2, '0')
51-
return `${year}.${month}.${day}.${hours}${minutes}${seconds}`
52-
}
53-
5456
// Clean version (remove 'v' prefix if present) or generate if not provided
5557
const cleanVersion = providedVersion
5658
? providedVersion.replace(/^v/, '')

0 commit comments

Comments
 (0)