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
25 changes: 25 additions & 0 deletions src/LanguageServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,31 @@ describe('LanguageServer', () => {
s`${tempDir}/root/subdir`
]);
});

it('finds nested roku-like dirs', async () => {
fsExtra.outputFileSync(s`${tempDir}/project1/manifest`, '');
fsExtra.outputFileSync(s`${tempDir}/project1/source/main.brs`, '');

fsExtra.outputFileSync(s`${tempDir}/sub/dir/project2/manifest`, '');
fsExtra.outputFileSync(s`${tempDir}/sub/dir/project2/source/main.bs`, '');

//does not match folder with manifest without a sibling ./source folder
fsExtra.outputFileSync(s`${tempDir}/project3/manifest`, '');

workspaceFolders = [
s`${tempDir}/`
];

server.run();
await server['syncProjects']();

expect(
server.projects.map(x => x.projectPath).sort()
).to.eql([
s`${tempDir}/project1`,
s`${tempDir}/sub/dir/project2`
]);
});
});

describe('onDidChangeWatchedFiles', () => {
Expand Down
30 changes: 27 additions & 3 deletions src/LanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,34 @@ export class LanguageServer {
//if we found at least one bsconfig.json, then ALL projects must have a bsconfig.json.
if (files.length > 0) {
return files.map(file => s`${path.dirname(file.src)}`);
} else {
//treat the workspace folder as a brightscript project itself
return [workspaceFolder];
}

//look for roku project folders
const rokuLikeDirs = (await Promise.all(
//find all folders containing a `manifest` file
(await rokuDeploy.getFilePaths([
'**/manifest',
...excludes

//is there at least one .bs|.brs file under the `/source` folder?
], workspaceFolder)).map(async manifestEntry => {
const manifestDir = path.dirname(manifestEntry.src);
const files = await rokuDeploy.getFilePaths([
'source/**/*.{brs,bs}',
...excludes
], manifestDir);
if (files.length > 0) {
return manifestDir;
}
})
//throw out nulls
)).filter(x => !!x);
if (rokuLikeDirs.length > 0) {
return rokuLikeDirs;
}

//treat the workspace folder as a brightscript project itself
return [workspaceFolder];
}

/**
Expand Down