@@ -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
@@ -24,7 +25,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
24
25
//look for a pseudo pattern by checking if there is a file containing same
25
26
//name, with ~ in it, ending in .json, .yml or .yaml
26
27
const needle =
27
- currentPattern . subdir + '/' + currentPattern . fileName + '~*.( json| yml| yaml) ' ;
28
+ currentPattern . subdir + '/' + currentPattern . fileName + '~*.{ json, yml, yaml} ' ;
28
29
const pseudoPatterns = glob . sync ( needle , {
29
30
cwd : paths . source . patterns ,
30
31
debug : false ,
@@ -45,7 +46,9 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
45
46
paths . source . patterns ,
46
47
pseudoPatterns [ i ]
47
48
) ;
48
- variantFileData = fs . readJSONSync ( variantFileFullPath ) ;
49
+ variantFileData = yaml . safeLoad (
50
+ fs . readFileSync ( variantFileFullPath , 'utf8' )
51
+ ) ;
49
52
} catch ( err ) {
50
53
logger . warning (
51
54
`There was an error parsing pseudopattern JSON for ${
@@ -65,9 +68,10 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
65
68
const variantName = pseudoPatterns [ i ]
66
69
. substring ( pseudoPatterns [ i ] . indexOf ( '~' ) + 1 )
67
70
. split ( '.' ) [ 0 ] ;
71
+ const variantExtension = pseudoPatterns [ i ] . split ( '.' ) . slice ( - 1 ) . pop ( ) ;
68
72
const variantFilePath = path . join (
69
73
currentPattern . subdir ,
70
- currentPattern . fileName + '~' + variantName + '.json'
74
+ currentPattern . fileName + '~' + variantName + '.' + variantExtension
71
75
) ;
72
76
const lm = fs . statSync ( variantFileFullPath ) ;
73
77
const patternVariant = Pattern . create (
0 commit comments