use absolute path (#6483)

This commit is contained in:
Alan Ren
2019-07-23 21:26:01 -07:00
committed by GitHub
parent a1a67b1a86
commit 059e80003d
3 changed files with 7 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ const localize = nls.loadMessageBundle();
export function activate(context: vscode.ExtensionContext) {
const platformService = new PlatformService();
const toolsService = new ToolsService();
const notebookService = new NotebookService(platformService);
const notebookService = new NotebookService(platformService, context.extensionPath);
const resourceTypeService = new ResourceTypeService(platformService, toolsService);
const resourceTypes = resourceTypeService.getResourceTypes();

View File

@@ -19,7 +19,7 @@ export interface INotebookService {
export class NotebookService implements INotebookService {
constructor(private platformService: IPlatformService) { }
constructor(private platformService: IPlatformService, private extensionPath: string) { }
/**
* Copy the notebook to the user's home directory and launch the notebook from there.
@@ -27,7 +27,7 @@ export class NotebookService implements INotebookService {
*/
launchNotebook(notebook: string | NotebookInfo): void {
const notebookRelativePath = this.getNotebook(notebook);
const notebookFullPath = path.join(__dirname, '../../', notebookRelativePath);
const notebookFullPath = path.join(this.extensionPath, notebookRelativePath);
if (notebookRelativePath && this.platformService.fileExists(notebookFullPath)) {
this.showNotebookAsUntitled(notebookFullPath);
}

View File

@@ -16,7 +16,7 @@ suite('Notebook Service Tests', function (): void {
test('getNotebook with string parameter', () => {
const mockPlatformService = TypeMoq.Mock.ofType<IPlatformService>();
const notebookService = new NotebookService(mockPlatformService.object);
const notebookService = new NotebookService(mockPlatformService.object, '');
const notebookInput = 'test-notebook.ipynb';
mockPlatformService.setup((service) => service.platform()).returns(() => { return 'win32'; });
let returnValue = notebookService.getNotebook(notebookInput);
@@ -32,7 +32,7 @@ suite('Notebook Service Tests', function (): void {
test('getNotebook with NotebookInfo parameter', () => {
const mockPlatformService = TypeMoq.Mock.ofType<IPlatformService>();
const notebookService = new NotebookService(mockPlatformService.object);
const notebookService = new NotebookService(mockPlatformService.object, '');
const notebookWin32 = 'test-notebook-win32.ipynb';
const notebookDarwin = 'test-notebook-darwin.ipynb';
const notebookLinux = 'test-notebook-linux.ipynb';
@@ -62,7 +62,7 @@ suite('Notebook Service Tests', function (): void {
test('findNextUntitledEditorName with no name conflict', () => {
const mockPlatformService = TypeMoq.Mock.ofType<IPlatformService>();
const notebookService = new NotebookService(mockPlatformService.object);
const notebookService = new NotebookService(mockPlatformService.object, '');
const notebookFileName = 'mynotebook.ipynb';
const sourceNotebookPath = `./notebooks/${notebookFileName}`;
@@ -76,7 +76,7 @@ suite('Notebook Service Tests', function (): void {
test('findNextUntitledEditorName with name conflicts', () => {
const mockPlatformService = TypeMoq.Mock.ofType<IPlatformService>();
const notebookService = new NotebookService(mockPlatformService.object);
const notebookService = new NotebookService(mockPlatformService.object, '');
const notebookFileName = 'mynotebook.ipynb';
const sourceNotebookPath = `./notebooks/${notebookFileName}`;
const expectedFileName = 'mynotebook-2';