* Add SystemContextProvider to context providers so that users can use their own system cpu and os for a resource * change to OSContextProvider * update descriptor
36 lines
772 B
TypeScript
36 lines
772 B
TypeScript
//os.platform()
|
|
//os.arch()
|
|
|
|
import { BaseContextProvider } from "..";
|
|
import {
|
|
ContextItem,
|
|
ContextProviderDescription,
|
|
ContextProviderExtras,
|
|
} from "../..";
|
|
import os from "os";
|
|
|
|
class OSContextProvider extends BaseContextProvider {
|
|
static description: ContextProviderDescription = {
|
|
title: "OS",
|
|
displayTitle: "OS",
|
|
description: "OS and CPU Information.",
|
|
type: "normal",
|
|
};
|
|
|
|
async getContextItems(
|
|
query: string,
|
|
extras: ContextProviderExtras,
|
|
): Promise<ContextItem[]> {
|
|
const cpu = os.arch();
|
|
const platform = os.platform();
|
|
return [
|
|
{
|
|
description: "Your OS and CPU",
|
|
content: `I am running ${platform} on ${cpu}.`,
|
|
name: "OS",
|
|
},
|
|
];
|
|
}
|
|
}
|
|
|
|
export default OSContextProvider;
|