1 | #!/usr/bin/env node
|
2 |
|
3 | 'use strict';
|
4 |
|
5 | const { resolve } = require('path');
|
6 |
|
7 | const program = require('commander');
|
8 |
|
9 | const { forIn, readYaml } = require('./utils');
|
10 |
|
11 |
|
12 |
|
13 | const TEST_COMPOSE_FILE = 'dc.test.yml';
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | const getTestVolumeNames = async () => {
|
22 | const composeFile = await readYaml(resolve(TEST_COMPOSE_FILE));
|
23 | const services = composeFile.services;
|
24 | let names = [];
|
25 |
|
26 |
|
27 | const regexp = /\$\{DX_VOLUMES\}\/(.*)\:/;
|
28 | forIn(services, (serviceSpec, serviceName) => {
|
29 | const volumes = serviceSpec.volumes;
|
30 | if (volumes) {
|
31 | volumes.forEach((volume) => {
|
32 | const matches = regexp.exec(volume);
|
33 | if (matches) {
|
34 | names.push(matches[1])
|
35 | }
|
36 | });
|
37 | }
|
38 | });
|
39 |
|
40 | return names;
|
41 | };
|
42 |
|
43 |
|
44 |
|
45 | program
|
46 | .version('0.1.0')
|
47 | .parse(process.argv);
|
48 |
|
49 | getTestVolumeNames(program)
|
50 | .then((names) => console.log(names.join(' ')))
|
51 | .catch((error) => {
|
52 | console.error(error);
|
53 | process.exit(1);
|
54 | });
|