Skip to content

Commit 31b804b

Browse files
committed
add web
1 parent 3884259 commit 31b804b

File tree

1 file changed

+11
-2
lines changed
  • packages/core/src/shared/fs

1 file changed

+11
-2
lines changed

packages/core/src/shared/fs/fs.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
isPermissionsError,
1717
scrubNames,
1818
} from '../errors'
19-
import globals from '../extensionGlobals'
19+
import globals, { isWeb } from '../extensionGlobals'
2020
import { isWin } from '../vscode/env'
2121
import { resolvePath } from '../utilities/pathUtils'
2222
import crypto from 'crypto'
@@ -549,6 +549,15 @@ export class FileSystem {
549549
* Follows the cache_dir convention outlined in https://crates.io/crates/dirs
550550
*/
551551
getCacheDir(): string {
552+
if (isWeb()) {
553+
const homeDir = this.#homeDir
554+
if (!homeDir) {
555+
throw new ToolkitError('Web home directory not found', {
556+
code: 'WebHomeDirectoryNotFound',
557+
})
558+
}
559+
return homeDir
560+
}
552561
switch (process.platform) {
553562
case 'darwin': {
554563
return _path.join(this.getUserHomeDir(), 'Library/Caches')
@@ -566,7 +575,7 @@ export class FileSystem {
566575
return _path.join(this.getUserHomeDir(), '.cache')
567576
}
568577
default: {
569-
throw new Error(`Unsupported platform: ${process.platform}. Expected 'darwin', 'win32', or 'linux'.`)
578+
throw new Error(`Unsupported platform: ${process.platform}. Expected 'darwin', 'win32', 'linux'.`)
570579
}
571580
}
572581
}

0 commit comments

Comments
 (0)