File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ const updatersByType = {
77 gradle : require ( './types/gradle' ) ,
88 csproj : require ( './types/csproj' ) ,
99 yaml : require ( './types/yaml' ) ,
10+ openapi : require ( './types/openapi' ) ,
1011} ;
1112const PLAIN_TEXT_BUMP_FILES = [ 'VERSION.txt' , 'version.txt' ] ;
1213
@@ -37,6 +38,9 @@ function getUpdaterByFilename(filename) {
3738 if ( / \. y a ? m l $ / . test ( filename ) ) {
3839 return getUpdaterByType ( 'yaml' ) ;
3940 }
41+ if ( / o p e n a p i .y a m l / . test ( filename ) ) {
42+ return getUpdaterByType ( 'openapi' ) ;
43+ }
4044 throw Error (
4145 `Unsupported file (${ filename } ) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.` ,
4246 ) ;
Original file line number Diff line number Diff line change 1+ const yaml = require ( 'yaml' ) ;
2+ const detectNewline = require ( 'detect-newline' ) ;
3+
4+ module . exports . readVersion = function ( contents ) {
5+ return yaml . parse ( contents ) . info . version ;
6+ } ;
7+
8+ module . exports . writeVersion = function ( contents , version ) {
9+ const newline = detectNewline ( contents ) ;
10+ const document = yaml . parseDocument ( contents ) ;
11+
12+ document . get ( 'info' ) . set ( 'version' , version ) ;
13+
14+ return document . toString ( ) . replace ( / \r ? \n / g, newline ) ;
15+ } ;
You can’t perform that action at this time.
0 commit comments