Skip to content

Commit

Permalink
Updated Readme gif, handle invalid json string in getter
Browse files Browse the repository at this point in the history
Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com>
  • Loading branch information
OmkarPh committed Oct 25, 2023
1 parent 2590b3e commit 9082b7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ ScanCode Workbench is based on
for using nexB’s [AboutCode tools](https://github.com/nexB/aboutcode). This app
works on Windows, OS X and Linux operating systems.

![ScanCode Workbench](https://user-images.githubusercontent.com/48476025/185114433-7340ee70-57cd-4586-b7e7-964fe736451a.gif)

![ScanCode Workbench](/src/assets/images/workbench_intro.gif)

## Using

Expand Down
Binary file added src/assets/images/workbench_intro.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ const Home = () => {
}

function historyItemParser(historyItem: HistoryItem) {
if (historyItem.json_path) {
// During development, re-parse JSON file (Possible schema changes)
// Toggle this if you don't have schema changes & wish to save time in imports
const REIMPORT_JSON_IN_DEV = true;

if (
REIMPORT_JSON_IN_DEV &&
process.env.NODE_ENV === "development" &&
historyItem.json_path
) {
console.log("Re-import JSON file (Dev mode)");
if (!electronFs.existsSync(historyItem.json_path)) {
return reportInvalidEntry(historyItem, "JSON");
}
Expand Down
3 changes: 2 additions & 1 deletion src/services/models/databaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Sequelize from "sequelize";
// eslint-disable-next-line import/no-unresolved
import { parse } from "license-expressions";
import { parseIfValidJson } from "../../utils/parsers";

// @TODO
// Store an object as a json string internally, but as an object externally
Expand All @@ -25,7 +26,7 @@ export function jsonDataType(attributeName: string) {
return {
type: Sequelize.STRING,
get: function () {
return JSON.parse(this.getDataValue(attributeName));
return parseIfValidJson(this.getDataValue(attributeName));
},
set: function (val: any) {
return this.setDataValue(attributeName, JSON.stringify(val));
Expand Down

0 comments on commit 9082b7c

Please sign in to comment.