Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 38997c3

Browse files
Pad build numbers so that alpha-sort produces correct ordering
1 parent bee4c6f commit 38997c3

File tree

1 file changed

+14
-3
lines changed
  • templates/package-builder/src/build

1 file changed

+14
-3
lines changed

templates/package-builder/src/build/build.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,20 @@ function copyRecursive(sourceRoot: string, destRoot: string, matchGlob: string)
8989
});
9090
}
9191

92-
function getBuildNumber() {
93-
return process.env.APPVEYOR_BUILD_NUMBER
94-
|| ('t-' + Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000)));
92+
function leftPad(str: string, minLength: number, padChar: string) {
93+
while (str.length < minLength) {
94+
str = padChar + str;
95+
}
96+
return str;
97+
}
98+
99+
function getBuildNumber(): string {
100+
if (process.env.APPVEYOR_BUILD_NUMBER) {
101+
return leftPad(process.env.APPVEYOR_BUILD_NUMBER, 6, '0');
102+
}
103+
104+
// For local builds, use timestamp
105+
return 't-' + Math.floor((new Date().valueOf() - new Date(2017, 0, 1).valueOf()) / (60*1000));
95106
}
96107

97108
function buildYeomanNpmPackage(outputRoot: string) {

0 commit comments

Comments
 (0)