import minimatch from "minimatch" ; import { Runtime , RuntimeDirEntry , RuntimeFileSystem , RuntimePath } from "./Runtime" ; const path = require ( "path-browserify" ) ; export class BrowserRuntime implements Runtime { fs = new BrowserRuntimeFileSystem ( ) ; path = new BrowserRuntimePath ( ) ; getEnvVar ( _name ) { return undefined ; } getEndOfLine ( ) { return "\n" ; } getPathMatchesPattern ( path , pattern ) { return minimatch ( path , pattern ) ; } } class BrowserRuntimePath implements RuntimePath { join ( ... paths ) { return path . join ( ... paths ) ; } normalize ( pathToNormalize ) { return path . normalize ( pathToNormalize ) ; } relative ( from , to ) { return path . relative ( from , to ) ; } } class BrowserRuntimeFileSystem implements RuntimeFileSystem { private _errorMessage = "Access to the file system is not supported in the browser. Please use an in-memory file system (specify `useInMemoryFileSystem: true` when creating the project)." ; delete ( _path ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } deleteSync ( _path ) { throw new Error ( this . _errorMessage ) ; } readDirSync ( _dirPath ) { throw new Error ( this . _errorMessage ) ; } readFile ( _filePath , _encoding ? ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } readFileSync ( _filePath , _encoding ? ) { throw new Error ( this . _errorMessage ) ; } writeFile ( _filePath , _fileText ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } writeFileSync ( _filePath , _fileText ) { throw new Error ( this . _errorMessage ) ; } mkdir ( _dirPath ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } mkdirSync ( _dirPath ) { throw new Error ( this . _errorMessage ) ; } move ( _srcPath , _destPath ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } moveSync ( _srcPath , _destPath ) { throw new Error ( this . _errorMessage ) ; } copy ( _srcPath , _destPath ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } copySync ( _srcPath , _destPath ) { throw new Error ( this . _errorMessage ) ; } fileExists ( _filePath ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } fileExistsSync ( _filePath ) { throw new Error ( this . _errorMessage ) ; } directoryExists ( _dirPath ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } directoryExistsSync ( _dirPath ) { throw new Error ( this . _errorMessage ) ; } realpathSync ( _path ) { throw new Error ( this . _errorMessage ) ; } getCurrentDirectory ( ) { throw new Error ( this . _errorMessage ) ; } glob ( _patterns ) { return Promise . reject ( new Error ( this . _errorMessage ) ) ; } globSync ( _patterns ) { throw new Error ( this . _errorMessage ) ; } isCaseSensitive ( ) { return true ; } }