@zohodesk/testinglibrary 0.1.8-eslint-16 → 0.1.8-eslint-18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,6 @@ async function runEslintForDiff(cliParams, options = {}) {
41
41
  });
42
42
  if (lint_process.stderr) {
43
43
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, lint_process.stderr.toString());
44
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `\n Linting Failed ...`);
45
44
  }
46
45
  if (lint_process.error) {
47
46
  throw lintFiles.error;
@@ -101,7 +100,7 @@ function filterDiffJson(diffJson) {
101
100
  return diffFilesMap;
102
101
  }
103
102
  function getRootDir() {
104
- return _path.default.resolve(process.cwd());
103
+ return process.cwd();
105
104
  }
106
105
  function getPathFromTestDir(diffPath) {
107
106
  if (!diffPath.includes('uat')) {
@@ -143,11 +142,13 @@ function getDiffJsonPath(diffJsonPath) {
143
142
  return _path.default.resolve(diffJsonPath);
144
143
  }
145
144
  function gitDiffFiles() {
146
- const command = 'git diff HEAD HEAD~1 --name-only';
145
+ const command = 'git diff --cached -U0 HEAD';
147
146
  const child = (0, _child_process.spawnSync)(command, {
148
147
  shell: true
149
148
  });
150
- return child.stdout.toString().split('\n').map(filePath => _path.default.resolve(getRootLintPath(), filePath));
149
+ const diffFiles = child.stdout.toString().split('\n').map(filePath => _path.default.resolve(getRootLintPath(), filePath));
150
+ diffFiles.pop(); // remove last empty string
151
+ return diffFiles;
151
152
  }
152
153
  function getRootLintPath() {
153
154
  const childProcess = (0, _child_process.spawnSync)('git', ['rev-parse', '--show-toplevel'], {
@@ -23,7 +23,6 @@ var _rootPath = require("../utils/rootPath");
23
23
 
24
24
  function runSonarAnalysis(cliParams) {
25
25
  var _getFilePathFrmReport, _getFilePathFrmReport2;
26
- _logger.Logger.log(_logger.Logger.INFO_TYPE, 'sending report to server ...');
27
26
  const {
28
27
  diffPath,
29
28
  repo,
@@ -49,7 +48,7 @@ function runSonarAnalysis(cliParams) {
49
48
  if (lintEnv == 'pre-commit') {
50
49
  resultFilesPath = (0, _eslintLintStage.gitDiffFiles)().join(',');
51
50
  }
52
- const command = ['-jar', sonar_scanner_path, `-Dsonar.host.url=${sonarqube_host_url}`, `-Dsonar.projectKey=${project_name}`, `-Dsonar.login=${Dlogin}`, `-Dsonar.password=${Dpassword}`, `-Dsonar.sources=${source_directories_str}`, `-Dsonar.tests=${resultFilesPath}`, '-Dsonar.language=js', `-Dsonar.eslint.reportPaths=${(0, _eslintLintStage.getReportPath)()}`, '-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info'];
51
+ const command = ['-jar', sonar_scanner_path, `-Dsonar.host.url=${sonarqube_host_url}`, `-Dsonar.projectKey=${project_name}`, `-Dsonar.login=${Dlogin}`, `-Dsonar.password=${Dpassword}`, `-Dsonar.sources=${source_directories_str}`, `-Dsonar.tests=${resultFilesPath}`, '-Dsonar.language=js', `-Dsonar.working.directory=${getSonarArtifactsDir()}`, `-Dsonar.eslint.reportPaths=${(0, _eslintLintStage.getReportPath)()}`, '-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info'];
53
52
  const child_process = (0, _child_process.spawn)('java', command);
54
53
  child_process.stdout.on('data', data => {
55
54
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
@@ -96,7 +95,7 @@ function getBranchName() {
96
95
  return branchName;
97
96
  }
98
97
  function getSpwanOutput(command, params = []) {
99
- const demon_process = (0, _child_process.spawnSync)(command, {
98
+ const demon_process = (0, _child_process.spawnSync)(command, params, {
100
99
  shell: true
101
100
  });
102
101
  return demon_process.stdout.toString().split('\n').filter(Boolean);
@@ -113,6 +112,9 @@ function getCredentials(login, password) {
113
112
  Dpassword: 'developer'
114
113
  };
115
114
  }
115
+ function getSonarArtifactsDir() {
116
+ return _path.default.resolve(process.cwd(), 'uat', 'lint-report', '.scannerwork');
117
+ }
116
118
 
117
119
  // import scanner from 'sonarqube-scanner';
118
120
  // import { generateConfigFromFile } from '../core/playwright/readConfigFile';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-16",
3
+ "version": "0.1.8-eslint-18",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {