@@ -7,9 +7,9 @@ import '@codeblitzjs/ide-core/languages';
7
7
import Select from 'antd/lib/select' ;
8
8
import 'antd/lib/select/style/index.css' ;
9
9
import { Button } from 'antd' ;
10
- import type { IFileServiceClient as TFileServiceClient } from '@opensumi/ide-file-service/lib/common' ;
11
10
12
11
const path = requireModule ( 'path' ) ;
12
+ const fse = requireModule ( 'fs-extra' ) ;
13
13
14
14
const dirMap : Record < string , [ string , FileType ] [ ] > = {
15
15
'/' : [
@@ -146,16 +146,8 @@ const App = () => {
146
146
< Button onClick = { async ( ) => {
147
147
// All files in codeblitz are mounted to /workspace/${workspaceDir}
148
148
const targetFile = path . join ( '/workspace' , workspaceDir , 'readme.md' ) ;
149
- const fileService = window . app . injector . get ( IFileServiceClient ) as TFileServiceClient ;
150
- const uri = Uri . file ( targetFile ) . toString ( ) ;
151
- const stat = await fileService . getFileStat ( uri ) ;
152
- if ( stat ) {
153
- const content = await fileService . readFile ( uri ) ;
154
- const text = content . content . toString ( ) ;
155
- await fileService . setContent ( stat , text + '\n\nThis is a demo file.' , {
156
- encoding : 'utf8' ,
157
- } ) ;
158
- }
149
+ const content = await fse . readFile ( targetFile ) ;
150
+ await fse . writeFile ( targetFile , content . toString ( ) + '\n\nThis is a demo file.' , { encoding : 'utf8' } ) ;
159
151
} } >
160
152
修改 readme.md
161
153
</ Button >
0 commit comments