From bd63536989e2fecd877be2e43adc345ad971b6d1 Mon Sep 17 00:00:00 2001 From: matthewfranglen Date: Wed, 19 Oct 2016 22:35:59 +0100 Subject: [PATCH] Remove file extension only when present If you name the machine to import without providing the extension then the old code will snip 4 characters off the end of the machine name. Since the `.zip` extension is added to the name later it would be fine to just pass the machine name, if the behaviour was changed to only remove the extension when it exists. The regular expression used for removal matches the behaviour of the import.sh script (specifically `"${filename%.*}"`. --- import.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/import.js b/import.js index faa6a04..b1f7662 100755 --- a/import.js +++ b/import.js @@ -15,7 +15,7 @@ if (!machine) { process.exit(1) } -var machine = machine.substring(0, machine.length - 4) +var machine = machine.replace(/\.[^.]*$/, '') var configDir = process.env.HOME + '/.docker/machine/machines/' + machine try { fs.statSync(configDir)