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:
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