-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_docker.js
More file actions
24 lines (21 loc) · 846 Bytes
/
start_docker.js
File metadata and controls
24 lines (21 loc) · 846 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
#!/usr/bin/env node
"use strict";
const fs = require("node:fs");
const { spawn } = require("node:child_process");
const { readInput, writeResponse, error } = require("@yoki/plugin-sdk");
const CANDIDATE_PATHS = [
`${process.env["ProgramFiles"]}\\Docker\\Docker\\Docker Desktop.exe`,
`${process.env["ProgramFiles(x86)"]}\\Docker\\Docker\\Docker Desktop.exe`,
`${process.env["LOCALAPPDATA"]}\\Programs\\Docker\\Docker\\Docker Desktop.exe`,
];
async function main() {
await readInput();
const found = CANDIDATE_PATHS.find((p) => p && fs.existsSync(p));
if (!found) {
writeResponse(error("Docker Desktop not found at standard paths", CANDIDATE_PATHS.join("\n")));
return;
}
spawn(found, [], { detached: true, stdio: "ignore" }).unref();
writeResponse({ type: "background", hud: "Starting Docker Desktop…" });
}
main();