MCPcopy Index your code
hub / github.com/devcontainers/cli / RemoteDocuments

Class RemoteDocuments

src/spec-configuration/editableFiles.ts:82–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82export class RemoteDocuments implements Documents {
83
84 static scheme = 'vscode-remote';
85
86 private static nonce: string | undefined;
87
88 constructor(private shellServer: ShellServer) {
89 }
90
91 async readDocument(uri: URI) {
92 switch (uri.scheme) {
93 case RemoteDocuments.scheme:
94 try {
95 const { stdout } = await this.shellServer.exec(`cat ${uri.path}`);
96 return stdout;
97 } catch (err) {
98 return undefined;
99 }
100 default:
101 throw new Error(`Unsupported scheme: ${uri.toString()}`);
102 }
103 }
104
105 async applyEdits(uri: URI, edits: Edit[], content: string) {
106 switch (uri.scheme) {
107 case RemoteDocuments.scheme:
108 try {
109 if (!RemoteDocuments.nonce) {
110 RemoteDocuments.nonce = crypto.randomUUID();
111 }
112 const result = jsonc.applyEdits(content, edits);
113 const eof = `EOF-${RemoteDocuments.nonce}`;
114 await this.shellServer.exec(`cat <<'${eof}' >${uri.path}
115${result}
116${eof}
117`);
118 } catch (err) {
119 console.log(err); // XXX
120 }
121 break;
122 default:
123 throw new Error(`Unsupported scheme: ${uri.toString()}`);
124 }
125 }
126}
127
128export class AllDocuments implements Documents {
129

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected