@@ -2,10 +2,10 @@ const path = require("path");
2
2
const fs = require ( "fs" ) ;
3
3
const crypto = require ( "crypto" ) ;
4
4
5
- const inputRef = process . env . GIT_REF ;
5
+ const gitRef = process . env . GIT_REF ;
6
6
let formulaRepoDir = process . env . FORMULA_REPO_DIR ;
7
7
8
- if ( ! inputRef ) {
8
+ if ( ! gitRef ) {
9
9
throw new Error ( "env 'GIT_REF' required" ) ;
10
10
}
11
11
@@ -17,13 +17,13 @@ if (!path.isAbsolute(formulaRepoDir)) {
17
17
formulaRepoDir = path . join ( process . cwd ( ) , formulaRepoDir ) ;
18
18
}
19
19
20
- const version = inputRef . replace ( / ^ r e f s \/ t a g s \/ v ? / , "" ) ;
20
+ const version = gitRef . replace ( / ^ r e f s \/ t a g s \/ v ? / , "" ) ;
21
21
22
22
const rbFile = path . join ( formulaRepoDir , "Formula" , "gpm.rs.rb" ) ;
23
23
24
- const formulaContent = fs . readFileSync ( rbFile , { encoding : "utf-8" } ) ;
24
+ let formulaContent = fs . readFileSync ( rbFile , { encoding : "utf-8" } ) ;
25
25
26
- let newContent = formulaContent . replace (
26
+ formulaContent = formulaContent . replace (
27
27
/ v e r s i o n \s " [ \w \. ] + " / g,
28
28
`version "${ version } "`
29
29
) ;
@@ -40,6 +40,9 @@ hashSum.update(fileBuffer);
40
40
41
41
const sha256 = hashSum . digest ( "hex" ) ;
42
42
43
- newContent = formulaContent . replace ( / s h a 2 5 6 \s " [ \w ] + " / g, `sha256 "${ sha256 } "` ) ;
43
+ formulaContent = formulaContent . replace (
44
+ / s h a 2 5 6 \s " [ \w ] + " / g,
45
+ `sha256 "${ sha256 } "`
46
+ ) ;
44
47
45
- fs . writeFileSync ( rbFile , newContent , { encoding : "utf-8" } ) ;
48
+ fs . writeFileSync ( rbFile , formulaContent , { encoding : "utf-8" } ) ;
0 commit comments