forked from jwplayer/jwplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.version.js
More file actions
25 lines (22 loc) · 775 Bytes
/
build.version.js
File metadata and controls
25 lines (22 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
/* eslint-env node */
/* eslint no-process-env: 0 */
const packageInfo = require('./package.json');
const env = process.env;
module.exports = () => {
// Build Version: {major.minor.revision}
let metadata = '';
if (env.BUILD_NUMBER) {
const branch = env.GIT_BRANCH;
metadata = 'opensource';
if (branch) {
metadata += '_' + branch.replace(/^origin\//, '').replace(/[^0-9A-Za-z-]/g, '-');
}
metadata += '.' + env.BUILD_NUMBER;
} else {
const now = new Date();
now.setTime(now.getTime() - now.getTimezoneOffset() * 60000);
metadata = 'local.' + now.toISOString().replace(/[.\-:T]/g, '-').replace(/Z|\.\d/g, '');
}
return `${packageInfo.version}+${metadata}`;
};