diff --git a/dist/index.js b/dist/index.js index e8068d8b..7947c8cf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -461,27 +461,27 @@ async function getChangedFilesOfPullRequest() { logger_1.logger.header('Retrieving changed files.'); let response; do { - response = await configuration_1.octokit.graphql(`query($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $after: String) { - rateLimit { - remaining - } - repository(owner: $owner, name: $repo) { - pullRequest(number: $pull_number) { - files(first: $per_page, after: $after) { - totalCount - pageInfo { - endCursor - hasNextPage - } - nodes { - path - changeType - additions - deletions - } - } - } - } + response = await configuration_1.octokit.graphql(`query($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $after: String) { + rateLimit { + remaining + } + repository(owner: $owner, name: $repo) { + pullRequest(number: $pull_number) { + files(first: $per_page, after: $after) { + totalCount + pageInfo { + endCursor + hasNextPage + } + nodes { + path + changeType + additions + deletions + } + } + } + } }`, params); files = files.concat(response.repository.pullRequest.files.nodes .map((item) => { @@ -1422,6 +1422,14 @@ async function buildRunCommand(fileListPath) { installCommand += ' &&'; } } + else { + if ((0, os_1.platform)() === 'linux') { + installCommand = `TICS='${configuration_1.ticsConfig.ticsConfiguration}';`; + } + else { + installCommand = `$env:TICS='${configuration_1.ticsConfig.ticsConfiguration}'`; + } + } if ((0, os_1.platform)() === 'linux') { return `/bin/bash -c "${installCommand} ${getTicsCommand(fileListPath)}"`; } diff --git a/package.json b/package.json index ea9dd369..eb9bc13b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "@tiobe/install-tics": "^0.4.0", "canonical-path": "^1.0.0", "compare-versions": "^6.1.0", - "crypto": "^1.0.1", "proxy-agent": "^6.3.1", "semver": "^7.5.4", "underscore": "^1.13.6" diff --git a/src/tics/analyzer.ts b/src/tics/analyzer.ts index 2f6a8fa3..e2d82ac4 100644 --- a/src/tics/analyzer.ts +++ b/src/tics/analyzer.ts @@ -72,6 +72,12 @@ async function buildRunCommand(fileListPath: string): Promise { if (platform() === 'linux') { installCommand += ' &&'; } + } else { + if (platform() === 'linux') { + installCommand = `TICS='${ticsConfig.ticsConfiguration}';`; + } else { + installCommand = `$env:TICS='${ticsConfig.ticsConfiguration}'`; + } } if (platform() === 'linux') { diff --git a/test/unit/tics/analyzer.test.ts b/test/unit/tics/analyzer.test.ts index e995f01f..62fa25d9 100644 --- a/test/unit/tics/analyzer.test.ts +++ b/test/unit/tics/analyzer.test.ts @@ -33,7 +33,7 @@ describe('test multiple types of configuration', () => { expect(response.statusCode).toEqual(0); expect(response.completed).toEqual(true); - expect(spy).toHaveBeenCalledWith('/bin/bash -c " TICS -ide github -help "', [], { + expect(spy).toHaveBeenCalledWith(`/bin/bash -c "TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github -help "`, [], { listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, silent: true }); @@ -50,10 +50,14 @@ describe('test multiple types of configuration', () => { expect(response.statusCode).toEqual(0); expect(response.completed).toEqual(true); - expect(spy).toHaveBeenCalledWith(`/bin/bash -c " TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE "`, [], { - listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, - silent: true - }); + expect(spy).toHaveBeenCalledWith( + `/bin/bash -c "TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE "`, + [], + { + listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, + silent: true + } + ); }); test('Should call exec with minimal TICS command for Windows', async () => { @@ -65,10 +69,14 @@ describe('test multiple types of configuration', () => { expect(response.statusCode).toEqual(0); expect(response.completed).toEqual(true); - expect(spy).toHaveBeenCalledWith(`powershell "; if ($?) {TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE }"`, [], { - listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, - silent: true - }); + expect(spy).toHaveBeenCalledWith( + `powershell "$env:TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; if ($?) {TICS -ide github '@/path/to' -viewer -project \'project\' -calc GATE }"`, + [], + { + listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, + silent: true + } + ); }); test('Should call exec with run TICS command for Linux', async () => { @@ -86,7 +94,7 @@ describe('test multiple types of configuration', () => { expect(response.statusCode).toEqual(0); expect(response.completed).toEqual(true); expect(spy).toHaveBeenCalledWith( - "/bin/bash -c \" TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9\"", + "/bin/bash -c \"TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9\"", [], { listeners: { stderr: expect.any(Function), stdout: expect.any(Function) }, @@ -110,7 +118,7 @@ describe('test multiple types of configuration', () => { expect(response.statusCode).toEqual(0); expect(response.completed).toEqual(true); expect(spy).toHaveBeenCalledWith( - "powershell \"; if ($?) {TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9}\"", + "powershell \"$env:TICS='http://base.com/tiobeweb/TICS/api/cfg?name=default'; if ($?) {TICS -ide github '@/path/to' -viewer -project 'project' -calc CS -cdtoken token -tmpdir '/home/ubuntu/test/123-1' -log 9}\"", [], { listeners: { stderr: expect.any(Function), stdout: expect.any(Function) },