Skip to content

Capitalize Activate.ps1 #9911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2020
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
1 change: 1 addition & 0 deletions news/2 Fixes/2607.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Capitalize `Activate.ps1` in code for PowerShell Core on Linux.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export class CommandPromptAndPowerShell extends BaseActivationCommandProvider {

if (targetShell === TerminalShellType.commandPrompt && scriptFile.endsWith('activate.bat')) {
return [scriptFile.fileToCommandArgument()];
} else if ((targetShell === TerminalShellType.powershell || targetShell === TerminalShellType.powershellCore) && scriptFile.endsWith('activate.ps1')) {
} else if ((targetShell === TerminalShellType.powershell || targetShell === TerminalShellType.powershellCore) && scriptFile.endsWith('Activate.ps1')) {
return [`& ${scriptFile.fileToCommandArgument()}`];
} else if (targetShell === TerminalShellType.commandPrompt && scriptFile.endsWith('activate.ps1')) {
} else if (targetShell === TerminalShellType.commandPrompt && scriptFile.endsWith('Activate.ps1')) {
// lets not try to run the powershell file from command prompt (user may not have powershell)
return [];
} else {
Expand All @@ -37,7 +37,7 @@ export class CommandPromptAndPowerShell extends BaseActivationCommandProvider {

private getScriptsInOrderOfPreference(targetShell: TerminalShellType): string[] {
const batchFiles = ['activate.bat', path.join('Scripts', 'activate.bat'), path.join('scripts', 'activate.bat')];
const powerShellFiles = ['activate.ps1', path.join('Scripts', 'activate.ps1'), path.join('scripts', 'activate.ps1')];
const powerShellFiles = ['Activate.ps1', path.join('Scripts', 'Activate.ps1'), path.join('scripts', 'Activate.ps1')];
if (targetShell === TerminalShellType.commandPrompt) {
return batchFiles.concat(powerShellFiles);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/test/common/terminals/activation.bash.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ suite('Terminal Environment Activation (bash)', () => {
const hasSpaces = pythonPath.indexOf(' ') > 0;
const suiteTitle = hasSpaces ? 'and there are spaces in the script file (pythonpath),' : 'and there are no spaces in the script file (pythonpath),';
suite(suiteTitle, () => {
['activate', 'activate.sh', 'activate.csh', 'activate.fish', 'activate.bat', 'activate.ps1'].forEach(scriptFileName => {
['activate', 'activate.sh', 'activate.csh', 'activate.fish', 'activate.bat', 'Activate.ps1'].forEach(scriptFileName => {
suite(`and script file is ${scriptFileName}`, () => {
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
let fileSystem: TypeMoq.IMock<IFileSystem>;
Expand Down
12 changes: 6 additions & 6 deletions src/test/common/terminals/activation.commandPrompt.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {

const suiteTitle = hasSpaces ? 'and there are spaces in the script file (pythonpath),' : 'and there are no spaces in the script file (pythonpath),';
suite(suiteTitle, () => {
['activate', 'activate.sh', 'activate.csh', 'activate.fish', 'activate.bat', 'activate.ps1'].forEach(scriptFileName => {
['activate', 'activate.sh', 'activate.csh', 'activate.fish', 'activate.bat', 'Activate.ps1'].forEach(scriptFileName => {
suite(`and script file is ${scriptFileName}`, () => {
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
let fileSystem: TypeMoq.IMock<IFileSystem>;
Expand All @@ -38,7 +38,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {
});

getNamesAndValues<TerminalShellType>(TerminalShellType).forEach(shellType => {
const isScriptFileSupported = ['activate.bat', 'activate.ps1'].indexOf(scriptFileName) >= 0;
const isScriptFileSupported = ['activate.bat', 'Activate.ps1'].indexOf(scriptFileName) >= 0;
const titleTitle = isScriptFileSupported
? `Ensure terminal type is supported (Shell: ${shellType.name})`
: `Ensure terminal type is not supported (Shell: ${shellType.name})`;
Expand Down Expand Up @@ -141,7 +141,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {
});
});

suite('and script file is activate.ps1', () => {
suite('and script file is Activate.ps1', () => {
let serviceContainer: TypeMoq.IMock<IServiceContainer>;
let fileSystem: TypeMoq.IMock<IFileSystem>;
let platform: TypeMoq.IMock<IPlatformService>;
Expand All @@ -163,7 +163,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {
const bash = new CommandPromptAndPowerShell(serviceContainer.object);

platform.setup(p => p.isWindows).returns(() => true);
const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1');
const pathToScriptFile = path.join(path.dirname(pythonPath), 'Activate.ps1');
fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true));
const command = await bash.getActivationCommands(resource, TerminalShellType.commandPrompt);

Expand All @@ -174,7 +174,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {
const bash = new CommandPromptAndPowerShell(serviceContainer.object);

platform.setup(p => p.isWindows).returns(() => true);
const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1');
const pathToScriptFile = path.join(path.dirname(pythonPath), 'Activate.ps1');
fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true));
const command = await bash.getActivationCommands(resource, TerminalShellType.powershell);

Expand All @@ -185,7 +185,7 @@ suite('Terminal Environment Activation (cmd/powershell)', () => {
const bash = new CommandPromptAndPowerShell(serviceContainer.object);

platform.setup(p => p.isWindows).returns(() => true);
const pathToScriptFile = path.join(path.dirname(pythonPath), 'activate.ps1');
const pathToScriptFile = path.join(path.dirname(pythonPath), 'Activate.ps1');
fileSystem.setup(fs => fs.fileExists(TypeMoq.It.isValue(pathToScriptFile))).returns(() => Promise.resolve(true));
const command = await bash.getActivationCommands(resource, TerminalShellType.powershellCore);

Expand Down