Implement fs module (#3)
* Implements the fs module * Add stats object * Add not implemented to createWriteStream * Update mkdtemp to use tmp dir * Unexport Stats * Add client web socket for commands and restructure
This commit is contained in:
9
packages/protocol/src/common/connection.ts
Normal file
9
packages/protocol/src/common/connection.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface SendableConnection {
|
||||
send(data: Buffer | Uint8Array): void;
|
||||
}
|
||||
|
||||
export interface ReadWriteConnection extends SendableConnection {
|
||||
onMessage(cb: (data: Uint8Array | Buffer) => void): void;
|
||||
onClose(cb: () => void): void;
|
||||
close(): void;
|
||||
}
|
||||
14
packages/protocol/src/common/util.ts
Normal file
14
packages/protocol/src/common/util.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Return true if we're in a browser environment (including web workers).
|
||||
*/
|
||||
export const isBrowserEnvironment = (): boolean => {
|
||||
return typeof process === "undefined" || typeof process.stdout === "undefined";
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape a path. This prevents any issues with file names that have quotes,
|
||||
* spaces, braces, etc.
|
||||
*/
|
||||
export const escapePath = (path: string): string => {
|
||||
return `'${path.replace(/'/g, "'\\''")}'`;
|
||||
};
|
||||
Reference in New Issue
Block a user