|
1 | 1 | #!/usr/bin/env node
|
2 | 2 |
|
3 |
| -'use strict'; |
| 3 | +'use strict' |
4 | 4 |
|
5 |
| -var fs = require('fs'); |
6 |
| -var shell = require('shelljs'); |
| 5 | +var fs = require('fs') |
| 6 | +var shell = require('shelljs') |
7 | 7 |
|
8 |
| -var getCommitHash = function() { |
9 |
| - //exec git command to get the hash of the current commit |
10 |
| - //git rev-parse HEAD |
| 8 | +var getCommitHash = function () { |
| 9 | + // exec git command to get the hash of the current commit |
| 10 | + // git rev-parse HEAD |
11 | 11 |
|
12 | 12 | var hash = shell.exec('git rev-parse HEAD', {
|
13 | 13 | silent: true
|
14 |
| - }).output.trim().substr(0, 7); |
15 |
| - return hash; |
| 14 | + }).output.trim().substr(0, 7) |
| 15 | + return hash |
16 | 16 | }
|
17 | 17 |
|
18 |
| -var commitHash = getCommitHash(); |
| 18 | +var commitHash = getCommitHash() |
19 | 19 |
|
| 20 | +var appConfig = JSON.parse(fs.readFileSync('./appConfig.json', 'utf8')) |
| 21 | +var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')) |
20 | 22 |
|
21 |
| -var appConfig = JSON.parse(fs.readFileSync('./appConfig.json', 'utf8')); |
22 |
| -var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); |
| 23 | +console.log('v' + pkg.version + ' #' + commitHash + ' App:' + appConfig.name) |
23 | 24 |
|
24 |
| -console.log('v' + pkg.version + ' #' + commitHash + ' App:' + appConfig.name); |
25 |
| - |
26 |
| - |
27 |
| -var content = 'window.version="' + pkg.version + '";'; |
28 |
| -content = content + '\nwindow.commitHash="' + commitHash + '";'; |
29 |
| - |
30 |
| -content = content + '\nwindow.appConfig=' + JSON.stringify(appConfig) + ';'; |
31 |
| -fs.writeFileSync("./src/js/appConfig.js", content); |
| 25 | +var content = 'window.version="' + pkg.version + '";' |
| 26 | +content = content + '\nwindow.commitHash="' + commitHash + '";' |
32 | 27 |
|
| 28 | +content = content + '\nwindow.appConfig=' + JSON.stringify(appConfig) + ';' |
| 29 | +fs.writeFileSync('./src/js/appConfig.js', content) |
0 commit comments