Skip to content

Commit

Permalink
Fix Json5 version issue in package dependencies (#1851)
Browse files Browse the repository at this point in the history
* Fix json5 package version

* Update
  • Loading branch information
EzioLi01 committed Nov 2, 2022
1 parent 7888898 commit 4dcc2e7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 36 deletions.
84 changes: 53 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@
"glob": "7.1.6",
"ip": "1.1.5",
"js-base64": "3.6.0",
"json5": "^2.2.1",
"json5": "^1.0.1",
"jsonc-parser": "3.0.0",
"mkdirp": "1.0.3",
"openssl-wrapper": "0.3.4",
Expand Down Expand Up @@ -1361,4 +1361,4 @@
"extensionDependencies": [
"ms-vscode.js-debug"
]
}
}
9 changes: 7 additions & 2 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { ChildProcess } from "./node/childProcess";
import { HostPlatform } from "./hostPlatform";
import customRequire from "./customRequire";
import stripJsonComments = require("strip-json-comments");
import { parse } from "json5";
import { logger } from "vscode-debugadapter";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const JSON5 = require("json5");

export function removeModuleFromRequireCacheByName(moduleName: string): void {
const moduleKey = Object.keys(customRequire.cache).find(key => key.includes(moduleName));
Expand Down Expand Up @@ -72,8 +75,10 @@ export function stripJsonTrailingComma(str: string): any {
const result = str.replace(endOfStringTrailingCommaRegex, "");
let objResult;
try {
objResult = parse(result);
logger.log("Start parsing .json file...");
objResult = JSON5.parse(result);
} catch {
logger.log("Failed to parse .json file. Try it again...");
objResult = JSON.parse(stripJsonComments(str));
}
return objResult;
Expand Down
1 change: 0 additions & 1 deletion src/extension/exponent/exponentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ require('${entryPoint}');`;
private async patchAppJson(isExpo: boolean = true): Promise<void> {
let appJson: AppJson;
try {
logger.log("Reading app.json file.");
appJson = await this.readAppJson();
} catch {
// If app.json doesn't exist, we will create it
Expand Down

0 comments on commit 4dcc2e7

Please sign in to comment.