File tree 5 files changed +34
-23
lines changed
5 files changed +34
-23
lines changed Original file line number Diff line number Diff line change 11
11
- run : ' npm i && npm run lint'
12
12
13
13
Tests :
14
- needs : [Lint]
15
14
runs-on : ${{ matrix.os }}
16
15
strategy :
17
16
matrix :
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
addLanguageAlias ,
14
14
getLanguageFromAlias ,
15
15
SOURCE_MAP_PROP_MAP ,
16
+ LANG_SPECIFIC_OPTIONS ,
16
17
} from './modules/language' ;
17
18
import { prepareContent } from './modules/prepareContent' ;
18
19
import { transformMarkup } from './modules/markup' ;
@@ -54,22 +55,6 @@ type AutoPreprocessOptions = {
54
55
[ languageName : string ] : TransformerOptions ;
55
56
} ;
56
57
57
- const LANG_SPECIFIC_OPTIONS : Record < string , any > = {
58
- sass : {
59
- indentedSyntax : true ,
60
- stripIndent : true ,
61
- } ,
62
- pug : {
63
- stripIndent : true ,
64
- } ,
65
- coffeescript : {
66
- stripIndent : true ,
67
- } ,
68
- stylus : {
69
- stripIndent : true ,
70
- } ,
71
- } ;
72
-
73
58
export const runTransformer = async (
74
59
name : string ,
75
60
options : TransformerOptions ,
@@ -133,12 +118,10 @@ export function sveltePreprocess(
133
118
Object . assign ( opts , nameOpts ) ;
134
119
}
135
120
136
- if ( name !== alias ) {
137
- Object . assign ( opts , LANG_SPECIFIC_OPTIONS [ alias ] || null ) ;
121
+ Object . assign ( opts , LANG_SPECIFIC_OPTIONS [ alias ] ) ;
138
122
139
- if ( typeof aliasOpts === 'object' ) {
140
- Object . assign ( opts , aliasOpts ) ;
141
- }
123
+ if ( name !== alias && typeof aliasOpts === 'object' ) {
124
+ Object . assign ( opts , aliasOpts ) ;
142
125
}
143
126
144
127
if ( sourceMap && name in SOURCE_MAP_PROP_MAP ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,22 @@ import { basename } from 'path';
2
2
3
3
import { PreprocessorArgs } from '../types' ;
4
4
5
+ export const LANG_SPECIFIC_OPTIONS : Record < string , any > = {
6
+ sass : {
7
+ indentedSyntax : true ,
8
+ stripIndent : true ,
9
+ } ,
10
+ pug : {
11
+ stripIndent : true ,
12
+ } ,
13
+ coffeescript : {
14
+ stripIndent : true ,
15
+ } ,
16
+ stylus : {
17
+ stripIndent : true ,
18
+ } ,
19
+ } ;
20
+
5
21
export const SOURCE_MAP_PROP_MAP : Record < string , [ string , any ] > = {
6
22
babel : [ 'sourceMaps' , true ] ,
7
23
typescript : [ 'sourceMap' , true ] ,
Original file line number Diff line number Diff line change @@ -89,7 +89,9 @@ describe(`sourcemap generation`, () => {
89
89
await preprocess ( template , opts ) ;
90
90
91
91
expect ( transformer ) . toHaveBeenCalledWith (
92
- expect . objectContaining ( { options : { [ key ] : val } } ) ,
92
+ expect . objectContaining ( {
93
+ options : expect . objectContaining ( { [ key ] : val } ) ,
94
+ } ) ,
93
95
) ;
94
96
} ) ;
95
97
} ,
Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ import sveltePreprocess from '../../src';
4
4
import { preprocess } from '../utils' ;
5
5
6
6
describe ( 'transformer - pug' , ( ) => {
7
+ it ( 'should de-indent if necessary' , async ( ) => {
8
+ const template = `<template lang="pug">
9
+ main
10
+ header
11
+ h1</template>` ;
12
+
13
+ const opts = sveltePreprocess ( ) ;
14
+ const preprocessed = await preprocess ( template , opts ) ;
15
+
16
+ expect ( preprocessed . code ) . toBe ( '<main><header><h1></h1></header></main>' ) ;
17
+ } ) ;
7
18
it ( 'should correctly prepend mixins with space TABS' , async ( ) => {
8
19
const template = `<template lang="pug">
9
20
main
You canβt perform that action at this time.
0 commit comments