Skip to content

Commit 07a512c

Browse files
committed
Fixup shell settings information
1 parent d4c8286 commit 07a512c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/providers/AuthProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class AuthProvider implements AuthenticationProvider, Disposable {
215215

216216
// Bring the editor to the front
217217
const wsFolder = await Folders.getWorkspaceFolder();
218-
exec('code .', { cwd: wsFolder?.uri.fsPath, shell: TerminalCommandExecuter.shell });
218+
exec('code .', { cwd: wsFolder?.uri.fsPath });
219219

220220
this.onDidChangeEventEmit.fire({ added: [account as any], removed: [], changed: [] });
221221

src/services/actions/Dependencies.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class Dependencies {
7575
let canProceedWithDependencyCheck = false;
7676
if (!isValidNode) {
7777
progress.report({ message: 'Node.js version not supported. Checking options...' });
78-
canProceedWithDependencyCheck = await Dependencies.HandleNotValidNodeVersion(spfxVersion.SupportedNodeVersions[spfxVersion.SupportedNodeVersions.length - 1], spfxVersion.SupportedNodeVersions);
78+
canProceedWithDependencyCheck = await Dependencies.HandleNotValidNodeVersion(spfxVersion.SupportedNodeVersions[spfxVersion.SupportedNodeVersions.length - 1], spfxVersion.SupportedNodeVersions, spfxVersion.Version);
7979
}
8080

8181
if (isValidNode || canProceedWithDependencyCheck) {
@@ -119,7 +119,7 @@ export class Dependencies {
119119
*/
120120
public static isValidNodeJs(SupportedNodeVersions: string[], NodeVersion: string | null = null): boolean {
121121
try {
122-
const output = NodeVersion ? `v${NodeVersion}` : execSync('node --version', { shell: TerminalCommandExecuter.shell });
122+
const output = NodeVersion ? `v${NodeVersion}` : execSync('node --version');
123123
const match = /v(?<major_version>\d+)\.(?<minor_version>\d+)\.(?<patch_version>\d+)/gm.exec(output.toString());
124124

125125
Logger.info(`Node.js version: ${output}`);
@@ -157,7 +157,7 @@ export class Dependencies {
157157
* @param supportedNodeVersions - An array of strings representing the supported Node.js versions for SPFx development
158158
* @returns A boolean indicating whether the invalid Node.js version was successfully handled
159159
*/
160-
private static HandleNotValidNodeVersion(requiredNodeVersions: string, supportedNodeVersions: string[]): boolean {
160+
private static HandleNotValidNodeVersion(requiredNodeVersions: string, supportedNodeVersions: string[], spfxVersion: string): boolean {
161161
const nodeVersionManager = getExtensionSettings<string>('nodeVersionManager', 'none');
162162
const isWindows = os.platform() === 'win32';
163163

@@ -167,7 +167,7 @@ export class Dependencies {
167167
const useNvsOption = 'Use NVS';
168168

169169
Notifications.warning(
170-
`Your Node.js version is not supported for SPFx v${requiredNodeVersions}.
170+
`Node.js v${requiredNodeVersions} is not supported for SPFx ${spfxVersion}.
171171
It is recommended to use a Node Version Manager to handle multiple Node.js versions
172172
and set SPFx Toolkit setting with your preferred Node Version Manager.
173173
Please select one of the options below to get help on installing or updating your Node.js version.`,
@@ -193,7 +193,7 @@ export class Dependencies {
193193
const requiredNodeVersionToInstall = requiredNodeVersions.replace(/x/g, '0');
194194
if (nodeVersionManager === NodeVersionManagers.nvm) {
195195
const nvmListCommand = isWindows ? 'list' : 'ls --no-alias';
196-
const nodeVersions = execSync(`nvm ${nvmListCommand}`, { shell: TerminalCommandExecuter.shell });
196+
const nodeVersions = execSync(`nvm ${nvmListCommand}`);
197197
const versions = isWindows ?
198198
nodeVersions.toString().split('\n').map(v => v.trim().replace(/^\*?\s*/, '').replace(/\s*\(.*\)$/, '').trim()).filter(v => v && /^\d+\.\d+\.\d+$/.test(v))
199199
: nodeVersions.toString().split('\n').map(v => v.trim().replace(/^(\*|->)?\s*/, '').replace(/\s*\(.*\)$/, '').replace(/^v/, '').trim()).filter(v => v && /^\d+\.\d+\.\d+$/.test(v));
@@ -203,7 +203,7 @@ export class Dependencies {
203203
const nvmInstallAndUseCommand = `nvm install ${requiredNodeVersionToInstall} && nvm use ${requiredNodeVersionToInstall}`;
204204
useNodeVersionOption = firstNodeValidVersion ? nvmUseCommand : nvmInstallAndUseCommand;
205205
} else {
206-
const nodeVersions = execSync('nvs list', { shell: TerminalCommandExecuter.shell });
206+
const nodeVersions = execSync('nvs list');
207207
const versions = nodeVersions.toString().split('\n').map(v => {
208208
const match = /node\/(\d+\.\d+\.\d+)/.exec(v.trim());
209209
return match ? match[1] : '';

src/services/executeWrappers/TerminalCommandExecuter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface ShellSetting {
1717
}
1818

1919
export class TerminalCommandExecuter {
20-
private static shellPath: string | undefined = undefined;
20+
private static shellPath: ShellSetting;
2121

2222
public static register() {
2323
const subscriptions: Subscription[] = Extension.getInstance().subscriptions;
@@ -292,9 +292,9 @@ export class TerminalCommandExecuter {
292292
const shell: string | ShellSetting | undefined = TerminalCommandExecuter.getShellPath();
293293

294294
if (typeof shell !== 'string' && !!shell) {
295-
TerminalCommandExecuter.shellPath = shell.path || shell.source;
295+
TerminalCommandExecuter.shellPath = shell;
296296
} else {
297-
TerminalCommandExecuter.shellPath = shell || undefined;
297+
TerminalCommandExecuter.shellPath.path = shell || undefined;
298298
}
299299
}
300300

@@ -389,7 +389,7 @@ export class TerminalCommandExecuter {
389389
private static getCommandChainOperator(): string {
390390
const shell = TerminalCommandExecuter.shell || '';
391391

392-
if (shell.includes('PowerShell') || shell.includes('pwsh')) {
392+
if (shell.path?.includes('PowerShell') || shell.path?.includes('pwsh') || shell.source?.includes('PowerShell') || shell.source?.includes('pwsh')) {
393393
return ';';
394394
}
395395

0 commit comments

Comments
 (0)