File tree 2 files changed +12
-8
lines changed
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'
2
2
import { Module } from '@nuxt/types'
3
3
import Vue from 'vue'
4
4
@@ -15,18 +15,22 @@ const websocketModule: Module<ModuleOptions> = function (moduleOptions) {
15
15
/* istanbul ignore next */
16
16
const options = Object . assign ( this . options [ CONFIG_KEY ] || { } , moduleOptions )
17
17
18
- const templatePath = join ( 'src' , 'templates' )
18
+ const webSocketManagerPath = require . resolve ( './templates/WebSocketManager' )
19
+ const pluginPath = require . resolve ( './templates/plugin' )
19
20
20
21
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
+ ) ,
23
27
options
24
28
} )
25
29
26
30
// Register plugin
27
31
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 ) } ` ) ,
30
34
options
31
35
} )
32
36
} ;
Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ describe('module', () => {
12
12
13
13
test ( 'should register the plugin' , ( ) => {
14
14
expectModuleToBeCalledWith ( 'addPlugin' , {
15
- src : ' src/templates/plugin.ts',
15
+ src : require . resolve ( '../ src/templates/plugin.ts') ,
16
16
fileName : 'nuxt-websocket/websocket.client.ts' ,
17
17
options : getNuxt ( ) . options . websocket
18
18
} )
19
19
} )
20
20
21
21
test ( 'should render the template' , ( ) => {
22
22
expectModuleToBeCalledWith ( 'addTemplate' , {
23
- src : ' src/templates/WebSocketManager.ts',
23
+ src : require . resolve ( '../ src/templates/WebSocketManager.ts') ,
24
24
fileName : 'nuxt-websocket/WebSocketManager.ts' ,
25
25
options : getNuxt ( ) . options . websocket
26
26
} )
You can’t perform that action at this time.
0 commit comments