-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputerName.ts
35 lines (32 loc) · 1.19 KB
/
computerName.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Placeholder, PlaceholderCategory, PlaceholderType } from "../types";
import { getComputerName } from "../scripts";
/**
* Placeholder for the 'pretty' hostname of the current machine. Barring any issues, this should always be replaced.
*
* Syntax: `{{computerName}}`
*/
const ComputerNamePlaceholder: Placeholder = {
name: "computerName",
regex: /{{computerName}}/g,
apply: async (str: string, context?: { [key: string]: unknown }) => {
if (context && "computerName" in context) {
return {
result: context["computerName"] as string,
computerName: context["computerName"] as string,
};
}
const name = await getComputerName();
return { result: name, computerName: name };
},
result_keys: ["computerName"],
constant: true,
fn: async () =>
(await ComputerNamePlaceholder.apply("{{computerName}}")).result,
example: "Come up with aliases for {{computerName}}",
description: "Replaced with the 'pretty' hostname of the current machine.",
hintRepresentation: "{{computerName}}",
fullRepresentation: "Computer Name",
type: PlaceholderType.Informational,
categories: [PlaceholderCategory.Device],
};
export default ComputerNamePlaceholder;