@@ -12,6 +12,7 @@ const logger = require('./log');
12
12
const readDocumentation = require ( './readDocumentation' ) ;
13
13
const lineage_hunter = new lh ( ) ;
14
14
const changes_hunter = new ch ( ) ;
15
+ const yaml = require ( 'js-yaml' ) ;
15
16
16
17
const pseudopattern_hunter = function ( ) { } ;
17
18
@@ -22,9 +23,12 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
22
23
const paths = patternlab . config . paths ;
23
24
24
25
//look for a pseudo pattern by checking if there is a file containing same
25
- //name, with ~ in it, ending in .json
26
+ //name, with ~ in it, ending in .json, .yml or .yaml
26
27
const needle =
27
- currentPattern . subdir + '/' + currentPattern . fileName + '~*.json' ;
28
+ currentPattern . subdir +
29
+ '/' +
30
+ currentPattern . fileName +
31
+ '~*.{json,yml,yaml}' ;
28
32
const pseudoPatterns = glob . sync ( needle , {
29
33
cwd : paths . source . patterns ,
30
34
debug : false ,
@@ -45,7 +49,9 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
45
49
paths . source . patterns ,
46
50
pseudoPatterns [ i ]
47
51
) ;
48
- variantFileData = fs . readJSONSync ( variantFileFullPath ) ;
52
+ variantFileData = yaml . safeLoad (
53
+ fs . readFileSync ( variantFileFullPath , 'utf8' )
54
+ ) ;
49
55
} catch ( err ) {
50
56
logger . warning (
51
57
`There was an error parsing pseudopattern JSON for ${
@@ -65,9 +71,13 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
65
71
const variantName = pseudoPatterns [ i ]
66
72
. substring ( pseudoPatterns [ i ] . indexOf ( '~' ) + 1 )
67
73
. split ( '.' ) [ 0 ] ;
74
+ const variantExtension = pseudoPatterns [ i ]
75
+ . split ( '.' )
76
+ . slice ( - 1 )
77
+ . pop ( ) ;
68
78
const variantFilePath = path . join (
69
79
currentPattern . subdir ,
70
- currentPattern . fileName + '~' + variantName + '.json'
80
+ currentPattern . fileName + '~' + variantName + '.' + variantExtension
71
81
) ;
72
82
const lm = fs . statSync ( variantFileFullPath ) ;
73
83
const patternVariant = Pattern . create (
0 commit comments