@@ -12,6 +12,7 @@ const logger = require('./log');
1212const readDocumentation = require ( './readDocumentation' ) ;
1313const lineage_hunter = new lh ( ) ;
1414const changes_hunter = new ch ( ) ;
15+ const yaml = require ( 'js-yaml' ) ;
1516
1617const pseudopattern_hunter = function ( ) { } ;
1718
@@ -24,7 +25,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
2425 //look for a pseudo pattern by checking if there is a file containing same
2526 //name, with ~ in it, ending in .json, .yml or .yaml
2627 const needle =
27- currentPattern . subdir + '/' + currentPattern . fileName + '~*.( json| yml| yaml) ' ;
28+ currentPattern . subdir + '/' + currentPattern . fileName + '~*.{ json, yml, yaml} ' ;
2829 const pseudoPatterns = glob . sync ( needle , {
2930 cwd : paths . source . patterns ,
3031 debug : false ,
@@ -45,7 +46,9 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
4546 paths . source . patterns ,
4647 pseudoPatterns [ i ]
4748 ) ;
48- variantFileData = fs . readJSONSync ( variantFileFullPath ) ;
49+ variantFileData = yaml . safeLoad (
50+ fs . readFileSync ( variantFileFullPath , 'utf8' )
51+ ) ;
4952 } catch ( err ) {
5053 logger . warning (
5154 `There was an error parsing pseudopattern JSON for ${
@@ -65,9 +68,10 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
6568 const variantName = pseudoPatterns [ i ]
6669 . substring ( pseudoPatterns [ i ] . indexOf ( '~' ) + 1 )
6770 . split ( '.' ) [ 0 ] ;
71+ const variantExtension = pseudoPatterns [ i ] . split ( '.' ) . slice ( - 1 ) . pop ( ) ;
6872 const variantFilePath = path . join (
6973 currentPattern . subdir ,
70- currentPattern . fileName + '~' + variantName + '.json'
74+ currentPattern . fileName + '~' + variantName + '.' + variantExtension
7175 ) ;
7276 const lm = fs . statSync ( variantFileFullPath ) ;
7377 const patternVariant = Pattern . create (
0 commit comments