Skip to content

Commit 4bb0970

Browse files
If version is specified, rebuild the image. If matchstick image already exists, delete it first
1 parent c74445e commit 4bb0970

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/commands/test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ${chalk.bold('graph test')} ${chalk.bold('<datasource>')} ${chalk.dim('[options]
1111
${chalk.dim('Options:')}
1212
-h, --help Show usage information
1313
-v, --version <tag> Choose the version of the rust binary that you want to be downloaded/used
14-
-c, --coverage Run tests in coverage mode
14+
-c, --coverage Run tests in coverage mode (works with v0.2.2 and above)
1515
-f, --flags <flags>
1616
`
1717

@@ -99,8 +99,7 @@ CMD ../binary-linux-20 \${ARGS}
9999
})
100100

101101
// TODOs:
102-
// 1. Fix true/false options with gluegun.
103-
// 2. If -v/--version is passed, delete current image and build again.
102+
// Fix true/false options with gluegun.
104103

105104
// Run a command to check if matchstick image already exists
106105
exec('docker images -q matchstick', (error, stdout, stderr) => {
@@ -128,8 +127,14 @@ CMD ../binary-linux-20 \${ARGS}
128127

129128
// If a matchstick image does not exists, the command returns an empty string,
130129
// else it'll return the image ID. Skip `docker build` if an image already exists
130+
// If `-v/--version` is specified, delete current image(if any) and rebuild.
131131
// Use spawn() and {stdio: 'inherit'} so we can see the logs in real time.
132-
if(stdout === "") {
132+
if(stdout === '' || version) {
133+
if (stdout !== '' && version) {
134+
exec('docker image rm matchstick', (error, stdout, stderr) => {
135+
print.info(chalk.bold(`Removing matchstick image\n${stdout}`));
136+
});
137+
}
133138
// Build a docker image. If the process has executed successfully
134139
// run a container from that image.
135140
spawn(

0 commit comments

Comments
 (0)