Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
fix(): scope manifest file detection to root of project
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Willis (HE / HIM) committed Apr 29, 2022
1 parent 5d8433a commit af62c84
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
41 changes: 24 additions & 17 deletions src/services/manifest/manifest-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,39 @@ export async function findManifest(manifestFile?: vscode.Uri[] | undefined) {
if (manifestFile && manifestFile.length > 0) {
manifest = manifestFile[0];
} else {
const mani = await vscode.workspace.findFiles(
"**/manifest.json",
"/node_modules/"
);

if (mani.length > 0) {
manifest = mani[0];
} else {
const maniTryTwo = await vscode.workspace.findFiles(
"**/web-manifest.json",
const rootFolder = vscode.workspace.workspaceFolders?.[0];
if (rootFolder) {

const mani = await vscode.workspace.findFiles(
new vscode.RelativePattern(rootFolder, 'manifest.json'),
"/node_modules/"
);

if (maniTryTwo.length > 0) {
manifest = maniTryTwo[0];
if (mani.length > 0) {
// check if file actually exists
const info = await vscode.workspace;
manifest = mani[0];
} else {
const maniTryThree = await vscode.workspace.findFiles(
"**/*.webmanifest",
const maniTryTwo = await vscode.workspace.findFiles(
new vscode.RelativePattern(rootFolder, 'web-manifest.json'),
"/node_modules/"
);

if (maniTryThree.length > 0) {
manifest = maniTryThree[0];

if (maniTryTwo.length > 0) {
manifest = maniTryTwo[0];
} else {
const maniTryThree = await vscode.workspace.findFiles(
new vscode.RelativePattern(rootFolder, "*.webmanifest"),
"/node_modules/"
);

if (maniTryThree.length > 0) {
manifest = maniTryThree[0];
}
}
}
}

}

if (manifest) {
Expand Down
4 changes: 4 additions & 0 deletions src/services/validation/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ function setupFileWatcher(): void {
await testManifest(manifestFileRead);
await vscode.commands.executeCommand("pwa-studio.refreshEntry");
});

watcher.onDidDelete(async (manifestFile) => {
await vscode.commands.executeCommand("pwa-studio.refreshEntry");
});
}

async function gatherResults(
Expand Down
1 change: 0 additions & 1 deletion src/views/manifest-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { writeFile } from "fs/promises";
import * as vscode from "vscode";
import {
convertBaseToFile,
findManifest,
} from "../services/manifest/manifest-service";
import { captureUsage } from "../services/usage-analytics";
import { getUri } from "../utils";
Expand Down

0 comments on commit af62c84

Please sign in to comment.