Skip to content

Commit 9082b7c

Browse files
committed
Updated Readme gif, handle invalid json string in getter
Signed-off-by: Omkar Phansopkar <[email protected]>
1 parent 2590b3e commit 9082b7c

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ ScanCode Workbench is based on
1515
for using nexB’s [AboutCode tools](https://github.com/nexB/aboutcode). This app
1616
works on Windows, OS X and Linux operating systems.
1717

18-
![ScanCode Workbench](https://user-images.githubusercontent.com/48476025/185114433-7340ee70-57cd-4586-b7e7-964fe736451a.gif)
19-
18+
![ScanCode Workbench](/src/assets/images/workbench_intro.gif)
2019

2120
## Using
2221

1.79 MB
Loading

src/pages/Home/Home.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ const Home = () => {
6060
}
6161

6262
function historyItemParser(historyItem: HistoryItem) {
63-
if (historyItem.json_path) {
63+
// During development, re-parse JSON file (Possible schema changes)
64+
// Toggle this if you don't have schema changes & wish to save time in imports
65+
const REIMPORT_JSON_IN_DEV = true;
66+
67+
if (
68+
REIMPORT_JSON_IN_DEV &&
69+
process.env.NODE_ENV === "development" &&
70+
historyItem.json_path
71+
) {
72+
console.log("Re-import JSON file (Dev mode)");
6473
if (!electronFs.existsSync(historyItem.json_path)) {
6574
return reportInvalidEntry(historyItem, "JSON");
6675
}

src/services/models/databaseUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import Sequelize from "sequelize";
1818
// eslint-disable-next-line import/no-unresolved
1919
import { parse } from "license-expressions";
20+
import { parseIfValidJson } from "../../utils/parsers";
2021

2122
// @TODO
2223
// Store an object as a json string internally, but as an object externally
@@ -25,7 +26,7 @@ export function jsonDataType(attributeName: string) {
2526
return {
2627
type: Sequelize.STRING,
2728
get: function () {
28-
return JSON.parse(this.getDataValue(attributeName));
29+
return parseIfValidJson(this.getDataValue(attributeName));
2930
},
3031
set: function (val: any) {
3132
return this.setDataValue(attributeName, JSON.stringify(val));

0 commit comments

Comments
 (0)