File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1- import { join } from 'path'
1+ import { extname , join } from 'path'
22import { Module } from '@nuxt/types'
33import Vue from 'vue'
44
@@ -15,18 +15,22 @@ const websocketModule: Module<ModuleOptions> = function (moduleOptions) {
1515 /* istanbul ignore next */
1616 const options = Object . assign ( this . options [ CONFIG_KEY ] || { } , moduleOptions )
1717
18- const templatePath = join ( 'src' , 'templates' )
18+ const webSocketManagerPath = require . resolve ( './templates/WebSocketManager' )
19+ const pluginPath = require . resolve ( './templates/plugin' )
1920
2021 this . addTemplate ( {
21- src : join ( templatePath , 'WebSocketManager.ts' ) ,
22- fileName : join ( 'nuxt-websocket' , 'WebSocketManager.ts' ) ,
22+ src : webSocketManagerPath ,
23+ fileName : join (
24+ 'nuxt-websocket' ,
25+ `WebSocketManager${ extname ( webSocketManagerPath ) } `
26+ ) ,
2327 options
2428 } )
2529
2630 // Register plugin
2731 this . addPlugin ( {
28- src : join ( templatePath , 'plugin.ts' ) ,
29- fileName : join ( 'nuxt-websocket' , ' websocket.client.ts' ) ,
32+ src : pluginPath ,
33+ fileName : join ( 'nuxt-websocket' , ` websocket.client${ extname ( pluginPath ) } ` ) ,
3034 options
3135 } )
3236} ;
Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ describe('module', () => {
1212
1313 test ( 'should register the plugin' , ( ) => {
1414 expectModuleToBeCalledWith ( 'addPlugin' , {
15- src : ' src/templates/plugin.ts',
15+ src : require . resolve ( '../ src/templates/plugin.ts') ,
1616 fileName : 'nuxt-websocket/websocket.client.ts' ,
1717 options : getNuxt ( ) . options . websocket
1818 } )
1919 } )
2020
2121 test ( 'should render the template' , ( ) => {
2222 expectModuleToBeCalledWith ( 'addTemplate' , {
23- src : ' src/templates/WebSocketManager.ts',
23+ src : require . resolve ( '../ src/templates/WebSocketManager.ts') ,
2424 fileName : 'nuxt-websocket/WebSocketManager.ts' ,
2525 options : getNuxt ( ) . options . websocket
2626 } )
You can’t perform that action at this time.
0 commit comments