Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit b5360b5

Browse files
hlovdaladiazulay
authored andcommitted
Remove arrow-head anti-pattern
1 parent 0356bb7 commit b5360b5

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

src/arduino/arduino.ts

+33-31
Original file line numberDiff line numberDiff line change
@@ -448,37 +448,39 @@ export class ArduinoApp {
448448
? dc.prebuild
449449
: dc.postbuild;
450450

451-
if (cmdline) {
452-
arduinoChannel.info(`Running ${what}-build command: "${cmdline}"`);
453-
let cmd: string;
454-
let args: string[];
455-
// pre-/post-build commands feature full bash support on UNIX systems.
456-
// On Windows you have full cmd support.
457-
if (os.platform() === "win32") {
458-
args = [];
459-
cmd = cmdline;
460-
} else {
461-
args = ["-c", cmdline];
462-
cmd = "bash";
463-
}
464-
try {
465-
await util.spawn(cmd,
466-
args,
467-
{
468-
shell: os.platform() === "win32",
469-
cwd: ArduinoWorkspace.rootPath,
470-
env: {...environment},
471-
},
472-
{ channel: arduinoChannel.channel });
473-
} catch (ex) {
474-
const msg = ex.error
475-
? `${ex.error}`
476-
: ex.code
477-
? `Exit code = ${ex.code}`
478-
: JSON.stringify(ex);
479-
arduinoChannel.error(`Running ${what}-build command failed: ${os.EOL}${msg}`);
480-
return false;
481-
}
451+
if (!cmdline) {
452+
return true; // Successfully done nothing.
453+
}
454+
455+
arduinoChannel.info(`Running ${what}-build command: "${cmdline}"`);
456+
let cmd: string;
457+
let args: string[];
458+
// pre-/post-build commands feature full bash support on UNIX systems.
459+
// On Windows you have full cmd support.
460+
if (os.platform() === "win32") {
461+
args = [];
462+
cmd = cmdline;
463+
} else {
464+
args = ["-c", cmdline];
465+
cmd = "bash";
466+
}
467+
try {
468+
await util.spawn(cmd,
469+
args,
470+
{
471+
shell: os.platform() === "win32",
472+
cwd: ArduinoWorkspace.rootPath,
473+
env: {...environment},
474+
},
475+
{ channel: arduinoChannel.channel });
476+
} catch (ex) {
477+
const msg = ex.error
478+
? `${ex.error}`
479+
: ex.code
480+
? `Exit code = ${ex.code}`
481+
: JSON.stringify(ex);
482+
arduinoChannel.error(`Running ${what}-build command failed: ${os.EOL}${msg}`);
483+
return false;
482484
}
483485
return true;
484486
}

0 commit comments

Comments
 (0)