Skip to content

Commit a290ae0

Browse files
Use IFileSystem.search() instead of glob().
1 parent 0b1554d commit a290ae0

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/client/common/platform/fileSystem.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ export class FileSystem implements IFileSystem {
173173
});
174174
});
175175
}
176-
public search(globPattern: string): Promise<string[]> {
176+
public search(globPattern: string, cwd?: string): Promise<string[]> {
177+
const options = {
178+
cwd: cwd
179+
};
177180
return new Promise<string[]>((resolve, reject) => {
178-
glob(globPattern, (ex, files) => {
181+
glob(globPattern, options, (ex, files) => {
179182
if (ex) {
180183
return reject(ex);
181184
}

src/client/datascience/themeFinder.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
'use strict';
4-
import * as glob from 'glob';
54
import { inject, injectable } from 'inversify';
65
import * as path from 'path';
76

@@ -107,14 +106,10 @@ export class ThemeFinder implements IThemeFinder {
107106

108107
// Search through all package.json files in the directory and below, looking
109108
// for the themeName in them.
110-
const foundPackages = await new Promise<string[]>((resolve, reject) => {
111-
glob('**/package.json', { cwd: rootPath }, (err, matches) => {
112-
if (err) {
113-
reject(err);
114-
}
115-
resolve(matches);
116-
});
117-
});
109+
const fs = new FileSystem(
110+
new PlatformService()
111+
);
112+
const foundPackages = await fs.search('**/package.json', rootPath);
118113
if (foundPackages.length > 0) {
119114
// For each one, open it up and look for the theme name.
120115
for (const f of foundPackages) {
@@ -167,14 +162,10 @@ export class ThemeFinder implements IThemeFinder {
167162
private async findMatchingThemes(rootPath: string, themeName: string) : Promise<IThemeData | undefined> {
168163
// Search through all package.json files in the directory and below, looking
169164
// for the themeName in them.
170-
const foundPackages = await new Promise<string []>((resolve, reject) => {
171-
glob('**/package.json', { cwd: rootPath }, (err, matches) => {
172-
if (err) {
173-
reject(err);
174-
}
175-
resolve(matches);
176-
});
177-
});
165+
const fs = new FileSystem(
166+
new PlatformService()
167+
);
168+
const foundPackages = await fs.search('**/package.json', rootPath);
178169
if (foundPackages.length > 0) {
179170
// For each one, open it up and look for the theme name.
180171
for (const f of foundPackages) {

0 commit comments

Comments
 (0)