Always use \n when passing to Jupyter (#14185)

This commit is contained in:
Chris LaFreniere
2021-02-08 09:38:06 -08:00
committed by GitHub
parent 06bace1fcf
commit b29c07adb3

View File

@@ -9,7 +9,6 @@ import * as fs from 'fs-extra';
import * as nls from 'vscode-nls';
import * as vscode from 'vscode';
import * as path from 'path';
import { EOL } from 'os';
import * as utils from '../common/utils';
const localize = nls.loadMessageBundle();
@@ -364,15 +363,15 @@ export class JupyterSession implements nb.ISession {
let allCode: string = '';
// Ensure cwd matches notebook path (this follows Jupyter behavior)
if (this.path && path.dirname(this.path)) {
allCode += `%cd ${path.dirname(this.path)}${EOL}`;
allCode += `%cd ${path.dirname(this.path)}\n`;
}
for (let i = 0; i < Object.keys(process.env).length; i++) {
let key = Object.keys(process.env)[i];
if (key.toLowerCase() === 'path' && this._pythonEnvVarPath) {
allCode += `%set_env ${key}=${this._pythonEnvVarPath}${EOL}`;
allCode += `%set_env ${key}=${this._pythonEnvVarPath}\n`;
} else {
// Jupyter doesn't seem to alow for setting multiple variables at once, so doing it with multiple commands
allCode += `%set_env ${key}=${process.env[key]}${EOL}`;
allCode += `%set_env ${key}=${process.env[key]}\n`;
}
}