-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-designed the flow and auto-updating the existing books & chapters …
…in the scope from the backend
- Loading branch information
Showing
5 changed files
with
143 additions
and
77 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
24 changes: 24 additions & 0 deletions
24
renderer/src/components/ProjectManagement/utils/updateBurritoScope.js
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,24 @@ | ||
import localForage from 'localforage'; | ||
import * as logger from '../../../logger'; | ||
import packageInfo from '../../../../../package.json'; | ||
|
||
export const updateBurritoScope = async (projectName, metadata) => { | ||
try { | ||
logger.debug('updateBurritoScope.js', `In update metadata - ${projectName}`); | ||
const currentUser = await localForage.getItem('userProfile'); | ||
const newpath = localStorage.getItem('userPath'); | ||
const fs = window.require('fs'); | ||
const path = require('path'); | ||
const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, 'projects'); | ||
// Finally updating the scope in the metadata | ||
const filePath = path.join(file, projectName, 'metadata.json'); | ||
if (fs.existsSync(filePath)) { | ||
fs.writeFileSync(filePath, JSON.stringify(metadata)); | ||
return true; | ||
} | ||
throw new Error(`failed to read metadata file - ${projectName}`); | ||
} catch (err) { | ||
logger.error('updateBurritoScope.js', `read metadata file successfully - ${projectName}`); | ||
throw new Error(err?.message || err); | ||
} | ||
}; |