Skip to content

Commit

Permalink
chore: auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2023
1 parent 3abc550 commit 1a448e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ export async function activate(context: ExtensionContext): Promise<void> {
);

context.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider("ansible",
new AnsibleDebugConfigurationProvider())
vscode.debug.registerDebugConfigurationProvider(
"ansible",
new AnsibleDebugConfigurationProvider()
)
);

context.subscriptions.push(
Expand Down
33 changes: 18 additions & 15 deletions src/features/utils/commandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export function withInterpreter(

const activationScript = settings.activationScript;
if (activationScript) {
const [command, shellArgs] = wrapWithActivationScript(activationScript, runExecutable, cmdArgs);
const [command, shellArgs] = wrapWithActivationScript(
activationScript,
runExecutable,
cmdArgs
);
return [`${command} ${shellArgs.join(" ")}`, undefined];
}

Expand All @@ -41,7 +45,7 @@ export function withInterpreter(

// emulating virtual environment activation script
const venvVars = buildPythonVirtualEnvVars(interpreterPath);
for (let key in venvVars) {
for (const key in venvVars) {
newEnv[key] = venvVars[key];
}
delete newEnv.PYTHONHOME;
Expand All @@ -60,14 +64,14 @@ export function withPythonModule(
settings: ExtensionSettings,
module: string,
moduleArgs: string[]
): [string, string[], {[key: string]: string}] {
): [string, string[], { [key: string]: string }] {
let command: string = "python";

let commandArgs: string[] = ["-m", module];
commandArgs.push(...moduleArgs);

const newEnv: {[key: string]: string} = {};
for (let e in process.env) {
const newEnv: { [key: string]: string } = {};
for (const e in process.env) {
newEnv[e] = process.env[e] ?? "";
}

Expand All @@ -79,10 +83,9 @@ export function withPythonModule(
command,
commandArgs.join(" ")
);
}
else if (interpreterPath) {
} else if (interpreterPath) {
const venvVars = buildPythonVirtualEnvVars(interpreterPath);
for (let key in venvVars) {
for (const key in venvVars) {
newEnv[key] = venvVars[key];
}
delete newEnv.PYTHONHOME;
Expand All @@ -104,11 +107,11 @@ export function withPythonModule(
function wrapWithActivationScript(
activationScript: string,
executable: string,
cmdArgs: string,
cmdArgs: string
): [string, string[]] {
return [
"bash",
["-c", `source ${activationScript} && ${executable} ${cmdArgs}`]
["-c", `source ${activationScript} && ${executable} ${cmdArgs}`],
];
}

Expand All @@ -118,14 +121,14 @@ function wrapWithActivationScript(
* @param interpreterPath The Python interpreter path.
* @returns The env vars that need to be set to run in the venv.
*/
function buildPythonVirtualEnvVars(
interpreterPath: string,
): { [key: string]: string } {
function buildPythonVirtualEnvVars(interpreterPath: string): {
[key: string]: string;
} {
const virtualEnv = path.resolve(interpreterPath, "../..");
const pathEntry = path.join(virtualEnv, "bin");

return {
VIRTUAL_ENV: virtualEnv,
PATH: `${pathEntry}${path.delimiter}${process.env.PATH}`
PATH: `${pathEntry}${path.delimiter}${process.env.PATH}`,
};
}
}
2 changes: 1 addition & 1 deletion src/interfaces/extensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export interface LightSpeedServiceSettings {
export interface DebuggerSettings {
logFile: string | null;
logLevel: string;
}
}

0 comments on commit 1a448e4

Please sign in to comment.