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 = {
7
7
gradle : require ( './types/gradle' ) ,
8
8
csproj : require ( './types/csproj' ) ,
9
9
yaml : require ( './types/yaml' ) ,
10
+ openapi : require ( './types/openapi' ) ,
10
11
} ;
11
12
const PLAIN_TEXT_BUMP_FILES = [ 'VERSION.txt' , 'version.txt' ] ;
12
13
@@ -37,6 +38,9 @@ function getUpdaterByFilename(filename) {
37
38
if ( / \. y a ? m l $ / . test ( filename ) ) {
38
39
return getUpdaterByType ( 'yaml' ) ;
39
40
}
41
+ if ( / o p e n a p i .y a m l / . test ( filename ) ) {
42
+ return getUpdaterByType ( 'openapi' ) ;
43
+ }
40
44
throw Error (
41
45
`Unsupported file (${ filename } ) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.` ,
42
46
) ;
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