-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·39 lines (30 loc) · 838 Bytes
/
index.js
File metadata and controls
executable file
·39 lines (30 loc) · 838 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
26
27
28
29
30
31
32
33
34
35
36
37
const path = require('path')
, updateCompose = require(path.join(__dirname, 'src/updateComposeFile.js'))
;
function processError (err) {
console.error('An error occured in node-docker-version');
console.error(err);
process.exit(1);
}
function processCompletion () {
console.log('docker-compose.yml updated with version');
process.exit(0);
}
// get version from package.json
try {
const manifest = require(path.join(process.env.PWD, 'package.json'))
, version = manifest.version
;
if (!version) {
processError('Could not find version in package.json');
} else {
// update compose file and dockerfile
updateCompose(process.env.PWD, version)
.then(processCompletion)
.catch(processError)
;
}
}
catch (err) {
processError('Could not locate package.json in directory');
}