-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edbd3e9
commit 3b8d1cc
Showing
9 changed files
with
86 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fileSystem from '@/lib/fs'; | ||
import { IDEContext } from '@/state/IDE.context'; | ||
import { useContext } from 'react'; | ||
import { baseProjectPath } from './projectV2.hooks'; | ||
|
||
const useFile = () => { | ||
const { activeProject } = useContext(IDEContext); | ||
const projectPath = `${baseProjectPath}${activeProject}`; | ||
const getFile = async (filePath: string) => { | ||
return fileSystem.readFile(`${projectPath}/${filePath}`); | ||
}; | ||
|
||
const saveFile = async (filePath: string, content: string) => { | ||
return fileSystem.writeFile(`${projectPath}/${filePath}`, content, { | ||
overwrite: true, | ||
}); | ||
}; | ||
|
||
return { | ||
getFile, | ||
saveFile, | ||
}; | ||
}; | ||
|
||
export default useFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as useFile } from './file.hooks'; | ||
export { default as useFileTab } from './fileTabs.hooks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters