From 059e80003db7edada8901a9e713b01756562480b Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Tue, 23 Jul 2019 21:26:01 -0700 Subject: [PATCH] use absolute path (#6483) --- extensions/resource-deployment/src/main.ts | 2 +- .../resource-deployment/src/services/notebookService.ts | 4 ++-- .../resource-deployment/src/test/notebookService.test.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/resource-deployment/src/main.ts b/extensions/resource-deployment/src/main.ts index e71e54f8b9..c6af2774aa 100644 --- a/extensions/resource-deployment/src/main.ts +++ b/extensions/resource-deployment/src/main.ts @@ -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(); diff --git a/extensions/resource-deployment/src/services/notebookService.ts b/extensions/resource-deployment/src/services/notebookService.ts index ba4a882eae..332842fb00 100644 --- a/extensions/resource-deployment/src/services/notebookService.ts +++ b/extensions/resource-deployment/src/services/notebookService.ts @@ -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); } diff --git a/extensions/resource-deployment/src/test/notebookService.test.ts b/extensions/resource-deployment/src/test/notebookService.test.ts index 36768d5176..8ab5b85ab0 100644 --- a/extensions/resource-deployment/src/test/notebookService.test.ts +++ b/extensions/resource-deployment/src/test/notebookService.test.ts @@ -16,7 +16,7 @@ suite('Notebook Service Tests', function (): void { test('getNotebook with string parameter', () => { const mockPlatformService = TypeMoq.Mock.ofType(); - 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(); - 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(); - 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(); - const notebookService = new NotebookService(mockPlatformService.object); + const notebookService = new NotebookService(mockPlatformService.object, ''); const notebookFileName = 'mynotebook.ipynb'; const sourceNotebookPath = `./notebooks/${notebookFileName}`; const expectedFileName = 'mynotebook-2';