From 5dca80cf76e7d5dea3eaca50720b406fcb85c6ac Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:02:52 -0500 Subject: [PATCH] lint --- dist/index.js | 144 +++++++++++++------------- src/buildExec.test.ts | 234 +++++++++++++++++++++--------------------- src/buildExec.ts | 212 ++++++++++++++++++++++++-------------- src/index.ts | 54 +++++----- 4 files changed, 354 insertions(+), 290 deletions(-) diff --git a/dist/index.js b/dist/index.js index a158a78be..dad764c70 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12309,7 +12309,7 @@ try { json: false, maxAttempts: 10, timeout: 3000, - url: "https://codecov.io/bash" + url: 'https://codecov.io/bash', }, function (error, response, body) { var _a = buildExec_1["default"](), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; try { @@ -12326,17 +12326,17 @@ try { else if (err) { core.warning("Codecov warning: " + err.message); } - var output = ""; - var execError = ""; + var output = ''; + var execError = ''; options.listeners = { stdout: function (data) { output += data.toString(); }, stderr: function (data) { execError += data.toString(); - } + }, }; - exec.exec("bash", execArgs, options)["catch"](function (err) { + exec.exec('bash', execArgs, options)["catch"](function (err) { if (fail_ci) { core.setFailed("Codecov failed with the following error: " + err.message); } @@ -54103,47 +54103,47 @@ exports.__esModule = true; var core = __webpack_require__(470); var isTrue = function (variable) { var lowercase = variable.toLowerCase(); - return (lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes"); + return (lowercase === '1' || + lowercase === 't' || + lowercase === 'true' || + lowercase === 'y' || + lowercase === 'yes'); }; var buildExec = function () { - var clean = core.getInput("move_coverage_to_trash"); - var commit_parent = core.getInput("commit_parent"); - var curl_aws_args = core.getInput("aws_curl_args"); - var curl_codecov_args = core.getInput("codecov_curl_args"); - var env_vars = core.getInput("env_vars"); - var fail_ci = isTrue(core.getInput("fail_ci_if_error")); - var file = core.getInput("file"); - var files = core.getInput("files"); - var flags = core.getInput("flags"); - var functionalities = core.getInput("functionalities"); - var gcov_args = core.getInput("gcov_args"); - var gcov_dir = core.getInput("gcov_root_dir"); - var gcov_exclude = core.getInput("gcov_path_exclude"); - var gcov_exec = core.getInput("gcov_executable"); - var gcov_include = core.getInput("gcov_path_include"); - var gcov_prefix = core.getInput("gcov_prefix"); - var name = core.getInput("name"); - var override_branch = core.getInput("override_branch"); - var override_build = core.getInput("override_build"); - var override_commit = core.getInput("override_commit"); - var override_pr = core.getInput("override_pr"); - var override_tag = core.getInput("override_tag"); - var root_dir = core.getInput("root_dir"); - var search_dir = core.getInput("directory"); - var token = core.getInput("token"); - var verbose = isTrue(core.getInput("verbose")); - var working_dir = core.getInput("working-directory"); - var write_path = core.getInput("path_to_write_report"); - var xcode_derived_data = core.getInput("xcode_derived_data"); - var xcode_package = core.getInput("xcode_package"); + var clean = core.getInput('move_coverage_to_trash'); + var commit_parent = core.getInput('commit_parent'); + var curl_aws_args = core.getInput('aws_curl_args'); + var curl_codecov_args = core.getInput('codecov_curl_args'); + var env_vars = core.getInput('env_vars'); + var fail_ci = isTrue(core.getInput('fail_ci_if_error')); + var file = core.getInput('file'); + var files = core.getInput('files'); + var flags = core.getInput('flags'); + var functionalities = core.getInput('functionalities'); + var gcov_args = core.getInput('gcov_args'); + var gcov_dir = core.getInput('gcov_root_dir'); + var gcov_exclude = core.getInput('gcov_path_exclude'); + var gcov_exec = core.getInput('gcov_executable'); + var gcov_include = core.getInput('gcov_path_include'); + var gcov_prefix = core.getInput('gcov_prefix'); + var name = core.getInput('name'); + var override_branch = core.getInput('override_branch'); + var override_build = core.getInput('override_build'); + var override_commit = core.getInput('override_commit'); + var override_pr = core.getInput('override_pr'); + var override_tag = core.getInput('override_tag'); + var root_dir = core.getInput('root_dir'); + var search_dir = core.getInput('directory'); + var token = core.getInput('token'); + var verbose = isTrue(core.getInput('verbose')); + var working_dir = core.getInput('working-directory'); + var write_path = core.getInput('path_to_write_report'); + var xcode_derived_data = core.getInput('xcode_derived_data'); + var xcode_package = core.getInput('xcode_package'); var filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh"; + working_dir + '/codecov.sh' : 'codecov.sh'; var execArgs = [filepath]; - execArgs.push("-n", "" + name, "-F", "" + flags, "-Q", "github-action"); + execArgs.push('-n', "" + name, '-F', "" + flags, '-Q', 'github-action'); var options = {}; options.env = Object.assign(process.env, { GITHUB_ACTION: process.env.GITHUB_ACTION, @@ -54151,10 +54151,10 @@ var buildExec = function () { GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); var env_vars_arg = []; - for (var _i = 0, _a = env_vars.split(","); _i < _a.length; _i++) { + for (var _i = 0, _a = env_vars.split(','); _i < _a.length; _i++) { var env_var = _a[_i]; var env_var_clean = env_var.trim(); if (env_var_clean) { @@ -54166,85 +54166,89 @@ var buildExec = function () { options.env.CODECOV_TOKEN = token; } if (clean) { - execArgs.push("-c"); + execArgs.push('-c'); } if (commit_parent) { - execArgs.push("-N", "" + commit_parent); + execArgs.push('-N', "" + commit_parent); } if (curl_aws_args) { - execArgs.push("-A", "" + curl_aws_args); + execArgs.push('-A', "" + curl_aws_args); } if (curl_codecov_args) { - execArgs.push("-U", "" + curl_codecov_args); + execArgs.push('-U', "" + curl_codecov_args); } if (env_vars_arg.length) { - execArgs.push("-e", env_vars_arg.join(",")); + execArgs.push('-e', env_vars_arg.join(',')); } if (fail_ci) { - execArgs.push("-Z"); + execArgs.push('-Z'); } if (file) { - execArgs.push("-f", "" + file); + execArgs.push('-f', "" + file); } if (files) { - files.split(',').forEach(function (f) { execArgs.push("-f", "" + f); }); + files.split(',').forEach(function (f) { + execArgs.push('-f', "" + f); + }); } if (functionalities) { - functionalities.split(',').forEach(function (f) { execArgs.push("-X", "" + f); }); + functionalities.split(',').forEach(function (f) { + execArgs.push('-X', "" + f); + }); } if (gcov_args) { - execArgs.push("-a", "" + gcov_args); + execArgs.push('-a', "" + gcov_args); } if (gcov_dir) { - execArgs.push("-p", "" + gcov_dir); + execArgs.push('-p', "" + gcov_dir); } if (gcov_exclude) { - execArgs.push("-g", "" + gcov_exclude); + execArgs.push('-g', "" + gcov_exclude); } if (gcov_exec) { - execArgs.push("-x", "" + gcov_exec); + execArgs.push('-x', "" + gcov_exec); } if (gcov_include) { - execArgs.push("-G", "" + gcov_include); + execArgs.push('-G', "" + gcov_include); } if (gcov_prefix) { - execArgs.push("-k", "" + gcov_prefix); + execArgs.push('-k', "" + gcov_prefix); } if (override_branch) { - execArgs.push("-B", "" + override_branch); + execArgs.push('-B', "" + override_branch); } if (override_build) { - execArgs.push("-b", "" + override_build); + execArgs.push('-b', "" + override_build); } if (override_commit) { - execArgs.push("-C", "" + override_commit); + execArgs.push('-C', "" + override_commit); } if (override_pr) { - execArgs.push("-P", "" + override_pr); + execArgs.push('-P', "" + override_pr); } if (override_tag) { - execArgs.push("-T", "" + override_tag); + execArgs.push('-T', "" + override_tag); } if (root_dir) { - execArgs.push("-N", "" + root_dir); + execArgs.push('-N', "" + root_dir); } if (search_dir) { - execArgs.push("-s", "" + search_dir); + execArgs.push('-s', "" + search_dir); } if (verbose) { - execArgs.push("-v"); + execArgs.push('-v'); } if (working_dir) { options.cwd = working_dir; } if (write_path) { - execArgs.push("-q", "" + write_path); + execArgs.push('-q', "" + write_path); } if (xcode_derived_data) { - execArgs.push("-D", "" + xcode_derived_data); + execArgs.push('-D', "" + xcode_derived_data); } if (xcode_package) { - execArgs.push("-J", "" + xcode_package); + execArgs.push('-J', "" + xcode_package); } return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; }; diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index 2c584b5e5..c4eceef8b 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -1,15 +1,15 @@ -import buildExec from "./buildExec"; +import buildExec from './buildExec'; test('no arguments', () => { - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); expect(execArgs).toEqual([ - "codecov.sh", - "-n", - "", - "-F", - "", - "-Q", - "github-action" + 'codecov.sh', + '-n', + '', + '-F', + '', + '-Q', + 'github-action', ]); expect(filepath).toEqual('codecov.sh'); expect(fail_ci).toBeFalsy(); @@ -17,121 +17,121 @@ test('no arguments', () => { test('all arguments', () => { const envs = { - "move_coverage_to_trash": "true", - "commit_parent": "83231650328f11695dfb754ca0f540516f188d27", - "aws_curl_args": "--timeout 1", - "codecov_curl_args": "--timeout 2", - "env_vars": "OS,PYTHON", - "fail_ci_if_error": "true", - "file": "coverage.xml", - "files": "dir1/coverage.xml,dir2/coverage.xml", - "flags": "test", - "functionalities" : "gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs", - "gcov_args": "--timeout 3", - "gcov_root_dr": "gcov_dir/", - "gcov_path_exclude": "**/exclude-dir/*.*", - "gcov_executable": "gcov", - "gcov_path_include": "**/include-dir/*.*", - "gcov_prefix": "demo", - "name": "codecov", - "override_branch": "thomasrockhu/test", - "override_build": "1", - "override_commit": "9caabca5474b49de74ef5667deabaf74cdacc244", - "override_pr": "2", - "override_tag": "v1.2", - "root_dir": "root/", - "directory": "coverage/", - "token": "d3859757-ab80-4664-924d-aef22fa7557b", - "verbose": "t", - "working-directory": "src", - "path_to_write_report": "codecov/", - "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", - "xcode_package": "MyApp" - } + 'move_coverage_to_trash': 'true', + 'commit_parent': '83231650328f11695dfb754ca0f540516f188d27', + 'aws_curl_args': '--timeout 1', + 'codecov_curl_args': '--timeout 2', + 'env_vars': 'OS,PYTHON', + 'fail_ci_if_error': 'true', + 'file': 'coverage.xml', + 'files': 'dir1/coverage.xml,dir2/coverage.xml', + 'flags': 'test', + 'functionalities': 'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs', + 'gcov_args': '--timeout 3', + 'gcov_root_dr': 'gcov_dir/', + 'gcov_path_exclude': '**/exclude-dir/*.*', + 'gcov_executable': 'gcov', + 'gcov_path_include': '**/include-dir/*.*', + 'gcov_prefix': 'demo', + 'name': 'codecov', + 'override_branch': 'thomasrockhu/test', + 'override_build': '1', + 'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244', + 'override_pr': '2', + 'override_tag': 'v1.2', + 'root_dir': 'root/', + 'directory': 'coverage/', + 'token': 'd3859757-ab80-4664-924d-aef22fa7557b', + 'verbose': 't', + 'working-directory': 'src', + 'path_to_write_report': 'codecov/', + 'xcode_derived_data': '~/Library/Developer/Xcode/DerivedData', + 'xcode_package': 'MyApp', + }; - for (let env of Object.keys(envs)) { - process.env["INPUT_" + env.toUpperCase()] = envs[env]; + for (const env of Object.keys(envs)) { + process.env['INPUT_' + env.toUpperCase()] = envs[env]; } - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); expect(execArgs).toEqual([ - "src/codecov.sh", - "-n", - "codecov", - "-F", - "test", - "-Q", - "github-action", - "-c", - "-N", - "83231650328f11695dfb754ca0f540516f188d27", - "-A", - "--timeout 1", - "-U", - "--timeout 2", - "-e", - "OS,PYTHON", - "-Z", - "-f", - "coverage.xml", - "-f", - "dir1/coverage.xml", - "-f", - "dir2/coverage.xml", - "-X", - "gcov", - "-X", - "coveragepy", - "-X", - "fix", - "-X", - "search", - "-X", - "code", - "-X", - "network", - "-X", - "gcovout", - "-X", - "html", - "-X", - "recursesubs", - "-a", - "--timeout 3", - "-g", - "**/exclude-dir/*.*", - "-x", - "gcov", - "-G", - "**/include-dir/*.*", - "-k", - "demo", - "-B", - "thomasrockhu/test", - "-b", - "1", - "-C", - "9caabca5474b49de74ef5667deabaf74cdacc244", - "-P", - "2", - "-T", - "v1.2", - "-N", - "root/", - "-s", - "coverage/", - "-v", - "-q", - "codecov/", - "-D", - "~/Library/Developer/Xcode/DerivedData", - "-J", - "MyApp", + 'src/codecov.sh', + '-n', + 'codecov', + '-F', + 'test', + '-Q', + 'github-action', + '-c', + '-N', + '83231650328f11695dfb754ca0f540516f188d27', + '-A', + '--timeout 1', + '-U', + '--timeout 2', + '-e', + 'OS,PYTHON', + '-Z', + '-f', + 'coverage.xml', + '-f', + 'dir1/coverage.xml', + '-f', + 'dir2/coverage.xml', + '-X', + 'gcov', + '-X', + 'coveragepy', + '-X', + 'fix', + '-X', + 'search', + '-X', + 'code', + '-X', + 'network', + '-X', + 'gcovout', + '-X', + 'html', + '-X', + 'recursesubs', + '-a', + '--timeout 3', + '-g', + '**/exclude-dir/*.*', + '-x', + 'gcov', + '-G', + '**/include-dir/*.*', + '-k', + 'demo', + '-B', + 'thomasrockhu/test', + '-b', + '1', + '-C', + '9caabca5474b49de74ef5667deabaf74cdacc244', + '-P', + '2', + '-T', + 'v1.2', + '-N', + 'root/', + '-s', + 'coverage/', + '-v', + '-q', + 'codecov/', + '-D', + '~/Library/Developer/Xcode/DerivedData', + '-J', + 'MyApp', ]); expect(filepath).toEqual('src/codecov.sh'); expect(fail_ci).toBeTruthy(); - for (let env of Object.keys(envs)) { - delete process.env["INPUT_" + env.toUpperCase()]; + for (const env of Object.keys(envs)) { + delete process.env['INPUT_' + env.toUpperCase()]; } }); diff --git a/src/buildExec.ts b/src/buildExec.ts index d4d2e2434..5b4d8569c 100644 --- a/src/buildExec.ts +++ b/src/buildExec.ts @@ -1,53 +1,53 @@ -const core = require("@actions/core"); +const core = require('@actions/core'); -let isTrue = (variable) => { +const isTrue = (variable) => { const lowercase = variable.toLowerCase(); return ( - lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes" + lowercase === '1' || + lowercase === 't' || + lowercase === 'true' || + lowercase === 'y' || + lowercase === 'yes' ); -} +}; -let buildExec = () => { - const clean = core.getInput("move_coverage_to_trash"); - const commit_parent = core.getInput("commit_parent"); - const curl_aws_args = core.getInput("aws_curl_args"); - const curl_codecov_args = core.getInput("codecov_curl_args"); - const env_vars = core.getInput("env_vars"); - const fail_ci = isTrue(core.getInput("fail_ci_if_error")); - const file = core.getInput("file"); - const files = core.getInput("files"); - const flags = core.getInput("flags"); - const functionalities = core.getInput("functionalities"); - const gcov_args = core.getInput("gcov_args"); - const gcov_dir = core.getInput("gcov_root_dir"); - const gcov_exclude = core.getInput("gcov_path_exclude"); - const gcov_exec = core.getInput("gcov_executable"); - const gcov_include = core.getInput("gcov_path_include"); - const gcov_prefix = core.getInput("gcov_prefix"); - const name = core.getInput("name"); - const override_branch = core.getInput("override_branch"); - const override_build = core.getInput("override_build"); - const override_commit = core.getInput("override_commit"); - const override_pr = core.getInput("override_pr"); - const override_tag = core.getInput("override_tag"); - const root_dir = core.getInput("root_dir"); - const search_dir = core.getInput("directory"); - const token = core.getInput("token"); - const verbose = isTrue(core.getInput("verbose")); - const working_dir = core.getInput("working-directory"); - const write_path = core.getInput("path_to_write_report"); - const xcode_derived_data = core.getInput("xcode_derived_data"); - const xcode_package = core.getInput("xcode_package"); +const buildExec = () => { + const clean = core.getInput('move_coverage_to_trash'); + const commit_parent = core.getInput('commit_parent'); + const curl_aws_args = core.getInput('aws_curl_args'); + const curl_codecov_args = core.getInput('codecov_curl_args'); + const env_vars = core.getInput('env_vars'); + const fail_ci = isTrue(core.getInput('fail_ci_if_error')); + const file = core.getInput('file'); + const files = core.getInput('files'); + const flags = core.getInput('flags'); + const functionalities = core.getInput('functionalities'); + const gcov_args = core.getInput('gcov_args'); + const gcov_dir = core.getInput('gcov_root_dir'); + const gcov_exclude = core.getInput('gcov_path_exclude'); + const gcov_exec = core.getInput('gcov_executable'); + const gcov_include = core.getInput('gcov_path_include'); + const gcov_prefix = core.getInput('gcov_prefix'); + const name = core.getInput('name'); + const override_branch = core.getInput('override_branch'); + const override_build = core.getInput('override_build'); + const override_commit = core.getInput('override_commit'); + const override_pr = core.getInput('override_pr'); + const override_tag = core.getInput('override_tag'); + const root_dir = core.getInput('root_dir'); + const search_dir = core.getInput('directory'); + const token = core.getInput('token'); + const verbose = isTrue(core.getInput('verbose')); + const working_dir = core.getInput('working-directory'); + const write_path = core.getInput('path_to_write_report'); + const xcode_derived_data = core.getInput('xcode_derived_data'); + const xcode_package = core.getInput('xcode_package'); const filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh" + working_dir + '/codecov.sh' : 'codecov.sh'; const execArgs = [filepath]; - execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); + execArgs.push( '-n', `${name}`, '-F', `${flags}`, '-Q', 'github-action' ); const options:any = {}; options.env = Object.assign(process.env, { @@ -56,48 +56,108 @@ let buildExec = () => { GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); - const env_vars_arg = [] - for (let env_var of env_vars.split(",")) { - let env_var_clean = env_var.trim(); + const env_vars_arg = []; + for (const env_var of env_vars.split(',')) { + const env_var_clean = env_var.trim(); if (env_var_clean) { options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean) + env_vars_arg.push(env_var_clean); } } - if (token) { options.env.CODECOV_TOKEN = token } - if (clean) { execArgs.push("-c"); } - if (commit_parent) { execArgs.push("-N", `${commit_parent}`); } - if (curl_aws_args) { execArgs.push("-A", `${curl_aws_args}`); } - if (curl_codecov_args) { execArgs.push("-U", `${curl_codecov_args}`); } - if (env_vars_arg.length) { execArgs.push("-e", env_vars_arg.join(",")); } - if (fail_ci) { execArgs.push("-Z"); } - if (file) { execArgs.push("-f", `${file}`); } - if (files) { files.split(',').forEach(f => { execArgs.push("-f", `${f}`); }); } - if (functionalities) { functionalities.split(',').forEach(f => { execArgs.push("-X", `${f}`); }); } - if (gcov_args) { execArgs.push("-a", `${gcov_args}`); } - if (gcov_dir) { execArgs.push("-p", `${gcov_dir}`); } - if (gcov_exclude) { execArgs.push("-g", `${gcov_exclude}`); } - if (gcov_exec) { execArgs.push("-x", `${gcov_exec}`); } - if (gcov_include) { execArgs.push("-G", `${gcov_include}`); } - if (gcov_prefix) { execArgs.push("-k", `${gcov_prefix}`); } - if (override_branch) { execArgs.push("-B", `${override_branch}`); } - if (override_build) { execArgs.push("-b", `${override_build}`); } - if (override_commit) { execArgs.push("-C", `${override_commit}`); } - if (override_pr) { execArgs.push("-P", `${override_pr}`); } - if (override_tag) { execArgs.push("-T", `${override_tag}`); } - if (root_dir) { execArgs.push("-N", `${root_dir}`); } - if (search_dir) { execArgs.push("-s", `${search_dir}`); } - if (verbose) { execArgs.push("-v"); } - if (working_dir) { options.cwd = working_dir; } - if (write_path) { execArgs.push("-q", `${write_path}`); } - if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } - if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } + if (token) { + options.env.CODECOV_TOKEN = token; + } + if (clean) { + execArgs.push('-c'); + } + if (commit_parent) { + execArgs.push('-N', `${commit_parent}`); + } + if (curl_aws_args) { + execArgs.push('-A', `${curl_aws_args}`); + } + if (curl_codecov_args) { + execArgs.push('-U', `${curl_codecov_args}`); + } + if (env_vars_arg.length) { + execArgs.push('-e', env_vars_arg.join(',')); + } + if (fail_ci) { + execArgs.push('-Z'); + } + if (file) { + execArgs.push('-f', `${file}`); + } + if (files) { + files.split(',').forEach((f) => { + execArgs.push('-f', `${f}`); + }); + } + if (functionalities) { + functionalities.split(',').forEach((f) => { + execArgs.push('-X', `${f}`); + }); + } + if (gcov_args) { + execArgs.push('-a', `${gcov_args}`); + } + if (gcov_dir) { + execArgs.push('-p', `${gcov_dir}`); + } + if (gcov_exclude) { + execArgs.push('-g', `${gcov_exclude}`); + } + if (gcov_exec) { + execArgs.push('-x', `${gcov_exec}`); + } + if (gcov_include) { + execArgs.push('-G', `${gcov_include}`); + } + if (gcov_prefix) { + execArgs.push('-k', `${gcov_prefix}`); + } + if (override_branch) { + execArgs.push('-B', `${override_branch}`); + } + if (override_build) { + execArgs.push('-b', `${override_build}`); + } + if (override_commit) { + execArgs.push('-C', `${override_commit}`); + } + if (override_pr) { + execArgs.push('-P', `${override_pr}`); + } + if (override_tag) { + execArgs.push('-T', `${override_tag}`); + } + if (root_dir) { + execArgs.push('-N', `${root_dir}`); + } + if (search_dir) { + execArgs.push('-s', `${search_dir}`); + } + if (verbose) { + execArgs.push('-v'); + } + if (working_dir) { + options.cwd = working_dir; + } + if (write_path) { + execArgs.push('-q', `${write_path}`); + } + if (xcode_derived_data) { + execArgs.push('-D', `${xcode_derived_data}`); + } + if (xcode_package) { + execArgs.push('-J', `${xcode_package}`); + } - return { execArgs, options, filepath, fail_ci }; -} + return {execArgs, options, filepath, fail_ci}; +}; export default buildExec; diff --git a/src/index.ts b/src/index.ts index 5162fa70f..4c9abf489 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -const core = require("@actions/core"); -const exec = require("@actions/exec"); -const fs = require("fs"); +const core = require('@actions/core'); +const exec = require('@actions/exec'); +const fs = require('fs'); const request = require('requestretry'); -import buildExec from "./buildExec"; +import buildExec from './buildExec'; let fail_ci; try { @@ -11,9 +11,9 @@ try { json: false, maxAttempts: 10, timeout: 3000, - url: "https://codecov.io/bash" + url: 'https://codecov.io/bash', }, (error, response, body) => { - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); try { if (error && fail_ci) { @@ -22,40 +22,40 @@ try { core.warning(`Codecov warning: ${error.message}`); } - fs.writeFile(filepath, body, err => { + fs.writeFile(filepath, body, (err) => { if (err && fail_ci) { throw err; } else if (err) { core.warning(`Codecov warning: ${err.message}`); } - let output = ""; - let execError = ""; + let output = ''; + let execError = ''; options.listeners = { - stdout: data => { + stdout: (data) => { output += data.toString(); }, - stderr: data => { + stderr: (data) => { execError += data.toString(); - } + }, }; - exec.exec("bash", execArgs, options) - .catch(err => { - if (fail_ci) { - core.setFailed( - `Codecov failed with the following error: ${err.message}` - ); - } else { - core.warning(`Codecov warning: ${err.message}`); - } - }) - .then(() => { - unlinkFile(); - }); + exec.exec('bash', execArgs, options) + .catch((err) => { + if (fail_ci) { + core.setFailed( + `Codecov failed with the following error: ${err.message}`, + ); + } else { + core.warning(`Codecov warning: ${err.message}`); + } + }) + .then(() => { + unlinkFile(); + }); const unlinkFile = () => { - fs.unlink(filepath, err => { + fs.unlink(filepath, (err) => { if (err && fail_ci) { throw err; } else if (err) { @@ -66,7 +66,7 @@ try { }); } catch (error) { core.setFailed( - `Codecov failed with the following error: ${error.message}` + `Codecov failed with the following error: ${error.message}`, ); } });