File tree 1 file changed +20
-16
lines changed
1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -60,24 +60,28 @@ const processFileChunk = async (crypt: CR, files: string[]): Promise<(ProcessOut
60
60
const commands = files . map ( async ( file ) => {
61
61
if ( ! crypt . condition || ( await crypt . condition ( file ) ) ) {
62
62
d . debug ( `${ crypt . cmd } ${ file } ` )
63
- const result = $ `${ crypt . cmd . split ( ' ' ) } ${ file } ` . quiet ( )
64
- return result
65
- . then ( async ( res ) => {
66
- if ( crypt . cmd === CryptType . DECRYPT ) {
67
- const outputFile = `${ file } .dec`
68
- await $ `echo ${ res . stdout } > ${ outputFile } `
69
- }
63
+ try {
64
+ d . info ( `${ crypt . cmd } ${ file } ` )
65
+ const result = await $ `${ [ ...crypt . cmd . split ( ' ' ) , file ] } ` . quiet ( )
66
+
67
+ if ( crypt . cmd === CryptType . DECRYPT ) {
68
+ const outputFile = `${ file } .dec`
69
+ await writeFile ( outputFile , result . stdout )
70
+ }
71
+
72
+ if ( crypt . post ) {
73
+ await crypt . post ( file )
74
+ }
75
+
76
+ return result
77
+ } catch ( error ) {
78
+ if ( error . message . includes ( 'Already encrypted' ) && ( await pathExists ( `${ file } .dec` ) ) ) {
79
+ const res = await $ `helm secrets encrypt ${ file } .dec`
80
+ await writeFile ( file , res . stdout )
70
81
if ( crypt . post ) await crypt . post ( file )
71
82
return res
72
- } )
73
- . catch ( async ( error ) => {
74
- if ( error . message . includes ( 'Already encrypted' ) && ( await pathExists ( `${ file } .dec` ) ) ) {
75
- const res = await $ `helm secrets encrypt ${ file } .dec`
76
- await $ `echo ${ res . stdout } > ${ file } `
77
- if ( crypt . post ) await crypt . post ( file )
78
- return res
79
- }
80
- } )
83
+ }
84
+ }
81
85
}
82
86
return undefined
83
87
} )
You can’t perform that action at this time.
0 commit comments