Skip to content

Commit 5e91c4a

Browse files
committed
feat: add script version info
1 parent 4d87451 commit 5e91c4a

9 files changed

Lines changed: 24 additions & 11 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const BASH_ENV_KEY = 'VSCODE_BASH_ACTIVATE';
22
export const ZSH_ENV_KEY = 'VSCODE_ZSH_ACTIVATE';
3+
export const BASH_SCRIPT_VERSION = '0.1.0';

src/features/terminal/shells/bash/bashStartup.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { traceError, traceInfo, traceVerbose } from '../../../../common/logging'
66
import { ShellConstants } from '../../../common/shellConstants';
77
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
88
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
9-
import { BASH_ENV_KEY, ZSH_ENV_KEY } from './bashConstants';
9+
import { BASH_ENV_KEY, BASH_SCRIPT_VERSION, ZSH_ENV_KEY } from './bashConstants';
1010

1111
async function isBashLikeInstalled(): Promise<boolean> {
1212
const result = await Promise.all([which('bash', { nothrow: true }), which('sh', { nothrow: true })]);
@@ -46,9 +46,12 @@ const regionEnd = '# <<< vscode python';
4646

4747
function getActivationContent(key: string): string {
4848
const lineSep = '\n';
49-
return [`if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`, ` eval "$${key}" || true`, 'fi'].join(
50-
lineSep,
51-
);
49+
return [
50+
`# version: ${BASH_SCRIPT_VERSION}`,
51+
`if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`,
52+
` eval "$${key}" || true`,
53+
'fi',
54+
].join(lineSep);
5255
}
5356

5457
async function isStartupSetup(profile: string, key: string): Promise<ShellSetupState> {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const CMD_ENV_KEY = 'VSCODE_CMD_ACTIVATE';
2+
export const CMD_SCRIPT_VERSION = '0.1.0';

src/features/terminal/shells/cmd/cmdStartup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { isWindows } from '../../../../common/utils/platformUtils';
99
import { ShellConstants } from '../../../common/shellConstants';
1010
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1111
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
12-
import { CMD_ENV_KEY } from './cmdConstants';
12+
import { CMD_ENV_KEY, CMD_SCRIPT_VERSION } from './cmdConstants';
1313

1414
const exec = promisify(cp.exec);
1515

@@ -61,7 +61,7 @@ const regionEnd = ':: <<< vscode python';
6161

6262
function getActivationContent(key: string): string {
6363
const lineSep = '\r\n';
64-
return [`if defined ${key} (`, ` call %${key}%`, ')'].join(lineSep);
64+
return [`:: version: ${CMD_SCRIPT_VERSION}`, `if defined ${key} (`, ` call %${key}%`, ')'].join(lineSep);
6565
}
6666

6767
function getHeader(): string {

src/features/terminal/shells/common/shellUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export function getShellDeactivationCommand(
7979
return deactivation;
8080
}
8181

82-
export const PROFILE_TAG_START = '###VSCODE_PROFILE_PATH_START###';
83-
export const PROFILE_TAG_END = '###VSCODE_PROFILE_PATH_END###';
82+
export const PROFILE_TAG_START = '###PATH_START###';
83+
export const PROFILE_TAG_END = '###PATH_END###';
8484
export function extractProfilePath(content: string): string | undefined {
8585
// Extract only the part between the tags
8686
const profilePathRegex = new RegExp(`${PROFILE_TAG_START}\\r?\\n(.*?)\\r?\\n${PROFILE_TAG_END}`, 's');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const FISH_ENV_KEY = 'VSCODE_FISH_ACTIVATE';
2+
export const FISH_SCRIPT_VERSION = '0.1.0';

src/features/terminal/shells/fish/fishStartup.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { traceError, traceInfo, traceVerbose } from '../../../../common/logging'
77
import { ShellConstants } from '../../../common/shellConstants';
88
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
99
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
10-
import { FISH_ENV_KEY } from './fishConstants';
10+
import { FISH_ENV_KEY, FISH_SCRIPT_VERSION } from './fishConstants';
1111

1212
async function isFishInstalled(): Promise<boolean> {
1313
try {
@@ -32,7 +32,12 @@ const regionEnd = '# <<< vscode python';
3232

3333
function getActivationContent(key: string): string {
3434
const lineSep = '\n';
35-
return [`if test "$TERM_PROGRAM" = "vscode"; and set -q ${key}`, ` eval $${key}`, 'end'].join(lineSep);
35+
return [
36+
`# version: ${FISH_SCRIPT_VERSION}`,
37+
`if test "$TERM_PROGRAM" = "vscode"; and set -q ${key}`,
38+
` eval $${key}`,
39+
'end',
40+
].join(lineSep);
3641
}
3742

3843
async function isStartupSetup(profilePath: string, key: string): Promise<boolean> {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const POWERSHELL_ENV_KEY = 'VSCODE_PWSH_ACTIVATE';
2+
export const PWSH_SCRIPT_VERSION = '0.1.0';

src/features/terminal/shells/pwsh/pwshStartup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { runCommand } from '../utils';
1010
import { ShellConstants } from '../../../common/shellConstants';
1111
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1212
import { extractProfilePath, PROFILE_TAG_END, PROFILE_TAG_START } from '../common/shellUtils';
13-
import { POWERSHELL_ENV_KEY } from './pwshConstants';
13+
import { POWERSHELL_ENV_KEY, PWSH_SCRIPT_VERSION } from './pwshConstants';
1414

1515
async function isPowerShellInstalled(shell: string): Promise<boolean> {
1616
try {
@@ -75,6 +75,7 @@ const regionEnd = '#endregion vscode python';
7575
function getActivationContent(): string {
7676
const lineSep = isWindows() ? '\r\n' : '\n';
7777
const activationContent = [
78+
`# version: ${PWSH_SCRIPT_VERSION}`,
7879
`if (($env:TERM_PROGRAM -eq 'vscode') -and ($null -ne $env:${POWERSHELL_ENV_KEY})) {`,
7980
' try {',
8081
` Invoke-Expression $env:${POWERSHELL_ENV_KEY}`,

0 commit comments

Comments
 (0)