Skip to content

Commit c1fb251

Browse files
authored
Add workspace setting to ignore specific project folder in multi-root workspace (#2061)
* Support ignore specific project in multi-root workspace * Update
1 parent d68e359 commit c1fb251

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,12 @@
12321232
"default": "Full",
12331233
"scope": "resource"
12341234
},
1235+
"react-native.workspace.exclude": {
1236+
"type": "array",
1237+
"description": "%reactNative.workspace.exclude.description%",
1238+
"scope": "resource",
1239+
"default": []
1240+
},
12351241
"react-native-tools.reactNativeGlobalCommandName": {
12361242
"description": "%reactNative.configuration.properties.react-native-tools.reactNativeGlobalCommandName.description%",
12371243
"type": "string",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"reactNative.launch.enableDebug.description": "Whether to enable debug mode. If set to \"false\", an application will be launched without debugging.",
8888
"reactNative.launch.openExpoQR.description": "Determines whether to open a tab with a QR code after launching the Expo server. If set to \"false\", a new tab with a QR code won't be opened after the Expo server starts.",
8989
"reactNative.configuration.title": "React Native configuration",
90+
"reactNative.workspace.exclude.description": "Exclude project folder in multi-root workspace",
9091
"reactNative.configuration.properties.react-native.ios.runArguments.simulator.description": "Run arguments to be passed to 'react-native run-ios' command",
9192
"reactNative.configuration.properties.react-native.ios.runArguments.device.description": "Run arguments to be passed to 'react-native run-ios' command",
9293
"reactNative.configuration.properties.react-native.ios.env.simulator.description": "Environment variables passed to the program.",

src/extension/rn-extension.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,19 @@ export function getCountOfWorkspaceFolders(): number {
284284
}
285285

286286
export async function onFolderAdded(folder: vscode.WorkspaceFolder): Promise<void> {
287+
const excludeFolders = await SettingsHelper.getWorkspaceFileExcludeFolder();
288+
let isExclude = false;
289+
if (excludeFolders.length != 0) {
290+
for (let i = 0; i < excludeFolders.length; i++) {
291+
if (folder.name == excludeFolders[i]) {
292+
isExclude = true;
293+
break;
294+
}
295+
}
296+
}
297+
if (isExclude) {
298+
return;
299+
}
287300
const rootPath = folder.uri.fsPath;
288301
const projectRootPath = SettingsHelper.getReactNativeProjectRoot(rootPath);
289302
outputChannelLogger.debug(`Add project: ${projectRootPath}`);

src/extension/settingsHelper.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for details.
33
import * as path from "path";
4+
import * as fs from "fs";
45
import * as vscode from "vscode";
56
import { ConfigurationReader } from "../common/configurationReader";
67
import { Packager } from "../common/packager";
@@ -204,4 +205,17 @@ export class SettingsHelper {
204205
await workspaceConfiguration.update("showUserTips", showTips, true);
205206
}
206207
}
208+
209+
public static async getWorkspaceFileExcludeFolder(): Promise<any> {
210+
const workspacePath = vscode.workspace.workspaceFile?.fsPath;
211+
const workspaceSettingsContent = workspacePath
212+
? JSON.parse(fs.readFileSync(workspacePath, "utf-8"))
213+
: null;
214+
if (workspaceSettingsContent) {
215+
const exclude = workspaceSettingsContent.settings["react-native.workspace.exclude"];
216+
return exclude ? exclude : [];
217+
} else {
218+
return [];
219+
}
220+
}
207221
}

0 commit comments

Comments
 (0)