allow comments in settings.json
This commit is contained in:
parent
e4d978da7c
commit
6cc0087105
|
@ -7067,7 +7067,6 @@
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
||||||
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
|
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
|
@ -8163,6 +8162,7 @@
|
||||||
"shell-quote": "^1.8.2",
|
"shell-quote": "^1.8.2",
|
||||||
"string-width": "^7.1.0",
|
"string-width": "^7.1.0",
|
||||||
"strip-ansi": "^7.1.0",
|
"strip-ansi": "^7.1.0",
|
||||||
|
"strip-json-comments": "^3.1.1",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
"shell-quote": "^1.8.2",
|
"shell-quote": "^1.8.2",
|
||||||
"string-width": "^7.1.0",
|
"string-width": "^7.1.0",
|
||||||
"strip-ansi": "^7.1.0",
|
"strip-ansi": "^7.1.0",
|
||||||
|
"strip-json-comments": "^3.1.1",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
import { MCPServerConfig } from '@gemini-code/server/src/config/config.js';
|
import { MCPServerConfig } from '@gemini-code/server/src/config/config.js';
|
||||||
|
import stripJsonComments from 'strip-json-comments';
|
||||||
|
|
||||||
export const SETTINGS_DIRECTORY_NAME = '.gemini';
|
export const SETTINGS_DIRECTORY_NAME = '.gemini';
|
||||||
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
|
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
|
||||||
|
@ -92,7 +93,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(USER_SETTINGS_PATH)) {
|
if (fs.existsSync(USER_SETTINGS_PATH)) {
|
||||||
const userContent = fs.readFileSync(USER_SETTINGS_PATH, 'utf-8');
|
const userContent = fs.readFileSync(USER_SETTINGS_PATH, 'utf-8');
|
||||||
userSettings = JSON.parse(userContent);
|
userSettings = JSON.parse(stripJsonComments(userContent));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reading user settings file:', error);
|
console.error('Error reading user settings file:', error);
|
||||||
|
@ -108,7 +109,7 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(workspaceSettingsPath)) {
|
if (fs.existsSync(workspaceSettingsPath)) {
|
||||||
const projectContent = fs.readFileSync(workspaceSettingsPath, 'utf-8');
|
const projectContent = fs.readFileSync(workspaceSettingsPath, 'utf-8');
|
||||||
workspaceSettings = JSON.parse(projectContent);
|
workspaceSettings = JSON.parse(stripJsonComments(projectContent));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reading workspace settings file:', error);
|
console.error('Error reading workspace settings file:', error);
|
||||||
|
|
Loading…
Reference in New Issue