@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
33import { Headers } from 'node-fetch' ;
44import * as base64 from 'base-64' ;
55import * as fs from 'fs' ;
6- import * as propertiesReader from 'properties-reader ' ;
6+ import { getProperties } from 'properties-file ' ;
77import * as xml2js from 'xml2js' ;
88import * as tmp from 'tmp' ;
99import { URL } from 'url' ;
@@ -293,15 +293,19 @@ export class IIQCommands {
293293 let env = uri . fsPath . split ( path . sep ) ;
294294 result . push ( env [ env . length - 2 ] . substring ( 4 ) ) ;
295295 } ) ;
296- return result ;
297296 } else {
298297 const uris = await vscode . workspace . findFiles ( `**/*.target.properties` ) ;
299298 uris . forEach ( ( uri ) => {
300299 let [ env , rest ] = path . basename ( uri . fsPath ) . split ( "." ) ;
301300 result . push ( env ) ;
302301 } ) ;
303- return result ;
304302 }
303+
304+ // Unique values only
305+ result = [ ...new Set ( result ) ] ;
306+
307+ return result ;
308+
305309 }
306310
307311 public getBaseSSBFolder ( ) : string | null {
@@ -346,19 +350,21 @@ export class IIQCommands {
346350 if ( 0 == uris . length ) {
347351 return null ;
348352 }
349- var uri = uris [ 0 ] ;
350- var filePath : string = uri . fsPath ;
353+ const uri = uris [ 0 ] ;
354+ const filePath : string = uri . fsPath ;
351355
352356 if ( this . canUseCachedProp ( filePath ) ) {
353357 return this . g_props [ filePath ] [ "props" ] ;
354358 }
355359
356360 this . g_props [ filePath ] = { "mtime" : null , "props" : { } } ;
357361 this . g_props [ filePath ] [ "mtime" ] = fs . statSync ( filePath ) . mtime ;
358- console . log ( `Trying to read ${ filePath } file` ) ;
359- var properties = propertiesReader ( filePath ) . getAllProperties ( ) ;
360- for ( var key in properties ) {
361- var val : string = properties [ key ] . toString ( ) ;
362+ this . g_iiqOutput . appendLine ( `Trying to read ${ filePath } file` ) ;
363+ let properties = getProperties ( fs . readFileSync ( filePath ) ) ;
364+
365+ // Is this needed?
366+ for ( let key in properties ) {
367+ let val : string = properties [ key ] . toString ( ) ;
362368 properties [ key ] = val . replace ( / \\ \\ / g, "\\" ) ;
363369 } ;
364370
@@ -388,7 +394,7 @@ export class IIQCommands {
388394 } else {
389395 secretProps = await this . getFileProperties ( `${ environment } .target.secret.properties` ) ;
390396 }
391- var allProps = Object . assign ( { } , mainProps , secretProps ) ;
397+ const allProps = Object . assign ( { } , mainProps , secretProps ) ;
392398 return allProps ;
393399 }
394400
@@ -1453,7 +1459,12 @@ export class IIQCommands {
14531459
14541460 }
14551461
1456- private async tokenizeWithDirectTokens ( xml ) {
1462+ /**
1463+ * Tokenizes the given XML string by replacing the tokens in the XML with their values from the properties
1464+ * @param xml The XML string to tokenize.
1465+ * @returns The tokenized XML string.
1466+ */
1467+ private async tokenizeWithDirectTokens ( xml : string ) : Promise < string > {
14571468 const exclusions = [
14581469 "%%ECLIPSE_URL%%" ,
14591470 "%%ECLIPSE_USER%%" ,
@@ -1462,7 +1473,7 @@ export class IIQCommands {
14621473 ] ;
14631474 const props = await this . loadTargetProps ( ) ;
14641475 const ignoreProps = await this . loadTokensToIgnore ( ) ;
1465- var ignorePropsList = Object . keys ( ignoreProps ) ;
1476+ let ignorePropsList = Object . keys ( ignoreProps ) ;
14661477 try {
14671478 for ( let key in props ) {
14681479 if ( exclusions . includes ( key ) || ignorePropsList . includes ( key ) ) {
@@ -1520,12 +1531,11 @@ export class IIQCommands {
15201531 return result ;
15211532 }
15221533
1523- private async tokenizeIIQObject ( xml ) {
1534+ private async tokenizeIIQObject ( xml : string ) : Promise < string > {
15241535 const reverseTokens = await this . loadReverseTokens ( ) ;
1525- if ( reverseTokens ) {
1536+ if ( reverseTokens ) {
15261537 return await this . tokenizeWithReverseTokens ( xml ) ;
1527- }
1528- else {
1538+ } else {
15291539 return await this . tokenizeWithDirectTokens ( xml ) ;
15301540 }
15311541 }
0 commit comments