Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-syncing",
"displayName": "vscode-syncing",
"description": "vscode-syncing extension",
"version": "0.2.2",
"version": "0.2.3",
"publisher": "sunerpy",
"icon": "resources/logo.png",
"engines": {
Expand All @@ -15,7 +15,6 @@
"categories": [
"Other"
],
"activationEvents": [],
"main": "./dist/extension.js",
"contributes": {
"commands": [
Expand Down Expand Up @@ -125,12 +124,13 @@
"prepare": "husky",
"lint": "eslint src",
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
"vscode:prepublish": "pnpm run package",
"vscode:prepublish": "npm run esbuild-base -- --minify",
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"compile": "pnpm run check-types && pnpm run lint && node esbuild.js",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "pnpm run check-types && pnpm run lint && node esbuild.js --production",
"package": "pnpm run vscode:prepublish",
"package:vsix": "pnpm run package && pnpm vsce package --no-dependencies",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
Expand Down Expand Up @@ -168,8 +168,5 @@
"prettier": "3.6.2",
"typescript": "^5.8.3"
},
"packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a",
"dependencies": {
"jsonc-parser": "^3.3.1"
}
}
"packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a"
}
4 changes: 0 additions & 4 deletions pnpm-lock.yaml

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

15 changes: 6 additions & 9 deletions src/dataCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
getPlatform,
} from './utils/vscodeEnvironment';
import { VSCodeEdition, Platform } from './types/vscodeEdition';
import * as jsonc from 'jsonc-parser';

export class DataCollector {
public readonly vscodeEdition: VSCodeEdition;
Expand Down Expand Up @@ -107,13 +106,13 @@ export class DataCollector {
// 获取用户设置
const userSettings = this.getUserSettings();
if (userSettings) {
settings.user = userSettings;
(settings as any).user = userSettings;
}

// 获取工作区设置
const workspaceSettings = this.getWorkspaceSettings();
if (workspaceSettings) {
settings.workspace = workspaceSettings;
(settings as any).workspace = workspaceSettings;
}

return settings;
Expand Down Expand Up @@ -215,12 +214,11 @@ export class DataCollector {
return snippets;
}

private getUserSettings(): Record<string, unknown> | null {
private getUserSettings(): string | null {
try {
const settingsPath = this.getUserSettingsPath();
if (fs.existsSync(settingsPath)) {
const content = fs.readFileSync(settingsPath, 'utf8');
return jsonc.parse(content);
return fs.readFileSync(settingsPath, 'utf8');
}
} catch (error) {
if (this.outputChannel) {
Expand All @@ -230,14 +228,13 @@ export class DataCollector {
return null;
}

private getWorkspaceSettings(): Record<string, unknown> | null {
private getWorkspaceSettings(): string | null {
try {
if (vscode.workspace.workspaceFolders) {
const workspaceFolder = vscode.workspace.workspaceFolders[0];
const settingsPath = path.join(workspaceFolder.uri.fsPath, '.vscode', 'settings.json');
if (fs.existsSync(settingsPath)) {
const content = fs.readFileSync(settingsPath, 'utf8');
return jsonc.parse(content);
return fs.readFileSync(settingsPath, 'utf8');
}
}
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export interface ExtensionsExport {
}

export interface SettingsExport {
user?: Record<string, unknown>;
workspace?: Record<string, unknown>;
user?: string;
workspace?: string;
}

export interface ThemeInfo {
Expand Down
Loading