Skip to content

Commit

Permalink
fix: support x.y.z
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jul 13, 2024
1 parent 6ea0f9e commit e836929
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/diagnostic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export async function updateDiagnostic(document: vscode.TextDocument) {
if (!configuration.depsVersionCheck.enable) return;

if (
document.uri.fsPath.includes('node_modules') ||
!path.basename(document.uri.fsPath).includes('package.json') ||
document.languageId !== 'json'
)
Expand All @@ -44,12 +43,19 @@ export async function updateDiagnostic(document: vscode.TextDocument) {
const parsed = getParsedByString(text);

async function checkDependency(key: string) {
const nodePath = key.split('.');
if (nodePath.length === 0) return;

let dependencies: Record<string, any> = packageJSON;
nodePath.forEach((node) => {
dependencies = dependencies[node] ?? {};
});
await Promise.all(
Object.entries(packageJSON[key] ?? {}).map(async ([name, version]) => {
Object.entries(dependencies).map(async ([name, version]) => {
if (typeof version !== 'string') return;

const location = getLocation(parsed, {
path: [key, name],
path: [...nodePath, name],
});

if (!location.start || !location.end) return;
Expand Down

0 comments on commit e836929

Please sign in to comment.