@@ -101,25 +101,28 @@ async function addInstructions(translationStringsData, args) {
101101 if ( translationStringsData . length !== 0 ) {
102102 const resourceIdBaseString = `o:${ args . org } :p:${ args . project } :r:${ args . resource } ` ;
103103
104- translationStringsData . forEach ( async ( value ) => {
104+ for ( let counter = 0 ; counter < translationStringsData . length ; counter += 1 ) {
105105 /*
106106 Convert string <hash>|<instructions> into list
107107 Get hash from the first element
108108 Join the remaining list with | as separator to get instructions. This join is done
109109 so that if the instruction string itself contained |, the splitted data length will
110110 be more than 2 and there might be chance of incomplete instruction being added to Transifex.
111111 */
112+ const value = translationStringsData [ counter ] ;
112113 const valueList = value . split ( "|" ) ;
113114 const hash = valueList [ 0 ] ;
114115 const instructions = valueList . slice ( 1 ) . join ( "|" ) ;
115116 const stringId = `${ resourceIdBaseString } :s:${ hash } ` ;
116117 process . stdout . write ( `Hash: ${ stringId } , Instructions: ${ instructions } \n` ) ;
118+ // eslint-disable-next-line no-await-in-loop
117119 await addStringInstructions ( stringId , instructions , args . token ) ;
118- } ) ;
120+ process . stdout . write ( `Instruction addition for Hash ${ stringId } completed\n` ) ;
121+ }
119122 }
120123}
121124
122- async function main ( ) {
125+ ( async function ( ) {
123126 const args = yargs . argv ;
124127 const inputFilePath = `${ args . inputFileDirectory } /hashed_data.txt` ;
125128 let inputData = [ ] ;
@@ -130,8 +133,4 @@ async function main() {
130133 process . stderr . write ( `Encountered an error while attempting to open ${ inputFilePath } \nError:${ error . message } \n` ) ;
131134 }
132135 await addInstructions ( inputData , args ) ;
133- }
134-
135- ( async function ( ) {
136- await main ( ) ;
137136} ( ) ) ;
0 commit comments