From 4346148207105aca43ad0cfa0e21a83afeb2c945 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Thu, 2 Mar 2017 10:17:40 +0300 Subject: [PATCH] Got rid of _.extend --- BuildServer/lib/commenter.ts | 10 ++++++++-- BuildServer/lib/report-processor.ts | 15 ++++++++++---- BuildServer/lib/status-processor.ts | 25 +++++++++++++++++------- BuildServer/lib/task-processor.ts | 5 +++-- BuildServer/lib/tasks/dotnetcompile.ts | 5 ++++- BuildServer/lib/tasks/dotnetnugetpack.ts | 5 +++-- BuildServer/lib/tasks/dotnetnugetpush.ts | 5 +++-- BuildServer/routes/manual.ts | 5 +++-- BuildServer/routes/status.ts | 10 ++++++++-- 9 files changed, 61 insertions(+), 24 deletions(-) diff --git a/BuildServer/lib/commenter.ts b/BuildServer/lib/commenter.ts index d980f3e..1d56b63 100644 --- a/BuildServer/lib/commenter.ts +++ b/BuildServer/lib/commenter.ts @@ -147,8 +147,14 @@ const checkPullRequest = (options, callback) => { }; export const commentOnPullRequest = (originalOptions, callback) => { - const optionsGithub = _.extend(originalOptions, { github: settings.createGithub(originalOptions.baseRepoOptions.owner) }); - const options = _.extend(optionsGithub, { onTenthAttempt: () => writeComment(optionsGithub, "Waiting for build to finish...", _.noop) }); + const optionsGithub = { + ...originalOptions, + github: settings.createGithub(originalOptions.baseRepoOptions.owner), + }; + const options = { + ...optionsGithub, + onTenthAttempt: () => writeComment(optionsGithub, "Waiting for build to finish...", _.noop), + }; return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => { const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength) diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts index 52520b8..394e853 100644 --- a/BuildServer/lib/report-processor.ts +++ b/BuildServer/lib/report-processor.ts @@ -98,20 +98,27 @@ export const loadReport = (app, options, callback) => { return readReport(releaseDir, (readErr, report) => { if (readErr) { - return callback(readErr, _.extend(options, { files })); + return callback(readErr, { + ...options, + files, + }); } - return callback(null, _.extend(options, { + return callback(null, { + ...options, files, report, - })); + }); }); }); }); }; export const getStatusMessageFromRelease = (app, originalOptions, callback) => { - const options = _.extend(originalOptions, { attemptsGetReport: (Number(originalOptions.attemptsGetReport) || Number()) + 1 }); + const options = { + ...originalOptions, + attemptsGetReport: (Number(originalOptions.attemptsGetReport) || Number()) + 1, + }; const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev); const reportFile = join(releaseDir, reportFilename); diff --git a/BuildServer/lib/status-processor.ts b/BuildServer/lib/status-processor.ts index 9c57f7a..63c385e 100644 --- a/BuildServer/lib/status-processor.ts +++ b/BuildServer/lib/status-processor.ts @@ -23,10 +23,11 @@ const addBranchInfo = (app, options, callback) => { const branchParts = branch.split("/"); const branchName = branchParts[branchParts.length - 1]; - return callback(null, _.extend(options, { + return callback(null, { + ...options, branch, branchName, - })); + }); }); }); }; @@ -46,7 +47,10 @@ const addRevInfo = (app, options, callback) => { const rev = data.toString(); - return callback(null, _.extend(options, { rev })); + return callback(null, { + ...options, + rev, + }); }); }); }; @@ -62,19 +66,26 @@ const parseOptions = (app, options, callback) => { }; if (options.rev) { - return addBranchInfo(app, _.extend(result, { rev: options.rev }), callback); + return addBranchInfo(app, { + ...result, + rev: options.rev, + }, callback); } if (/^[\da-f]{40}$/i.test(options.branchName)) { - return addBranchInfo(app, _.extend(result, { rev: options.branchName }), callback); + return addBranchInfo(app, { + ...result, + rev: options.branchName, + }, callback); } const branchName = options.branchName || "master"; - return addRevInfo(app, _.extend(result, { + return addRevInfo(app, { + ...result, branch: `refs/heads/${branchName}`, branchName, - }), callback); + }, callback); }; export const getReport = (app, options, callback) => parseOptions(app, options, (err, result) => { diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts index f08f2c1..1f0c874 100644 --- a/BuildServer/lib/task-processor.ts +++ b/BuildServer/lib/task-processor.ts @@ -78,10 +78,11 @@ export const processTask = (task, context, callback) => { }; const flags = {}; const processor = createTaskProcessor(task, { - context: _.extend(context, { + context: { + ...context, addFlag: addFlag(flags), containsFlag: containsFlag(flags), - }), + }, onError: messageProcessor(errors), onInfo: messageProcessor(infos), onWarn: messageProcessor(warns), diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts index ecdc2ff..be0ad81 100644 --- a/BuildServer/lib/tasks/dotnetcompile.ts +++ b/BuildServer/lib/tasks/dotnetcompile.ts @@ -35,5 +35,8 @@ export default ((params, processor) => { command: "compile", }; - return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor); + return dotnetbuilderwrapper({ + ...compileParams, + ...getAdditionalSigningParameters(), + }, processor); }) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts index 776361a..7b39a1c 100644 --- a/BuildServer/lib/tasks/dotnetnugetpack.ts +++ b/BuildServer/lib/tasks/dotnetnugetpack.ts @@ -5,9 +5,10 @@ import * as _ from "underscore"; import { Task } from "../../types"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; -export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { +export default ((params, processor) => dotnetnugetprocessinternal({ + ...params, getFinalTask: (nupkg) => ({ params: { filename: nupkg }, type: "copy", }), -}), processor)) as Task; +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts index 377c9f2..147121a 100644 --- a/BuildServer/lib/tasks/dotnetnugetpush.ts +++ b/BuildServer/lib/tasks/dotnetnugetpush.ts @@ -5,9 +5,10 @@ import * as _ from "underscore"; import { Task } from "../../types"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; -export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { +export default ((params, processor) => dotnetnugetprocessinternal({ + ...params, getFinalTask: (nupkg) => ({ params: { Package: nupkg }, type: "dotnetnugetpushonly", }), -}), processor)) as Task; +}, processor)) as Task; diff --git a/BuildServer/routes/manual.ts b/BuildServer/routes/manual.ts index c9f7cc2..f868501 100644 --- a/BuildServer/routes/manual.ts +++ b/BuildServer/routes/manual.ts @@ -6,10 +6,11 @@ import { build } from "../lib/builder"; export const get = (req, res) => res.render("manual"); export const post = (req, res) => { - const options = _.extend(req.body, { + const options = { + ...req.body, app: req.app, url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`, - }); + }; build(options, (err, result) => { console.log("Done processing manual request"); diff --git a/BuildServer/routes/status.ts b/BuildServer/routes/status.ts index 11bd3a6..bd08225 100644 --- a/BuildServer/routes/status.ts +++ b/BuildServer/routes/status.ts @@ -35,7 +35,10 @@ const parseOptionsFromReferer = (path, callback) => { }; const createShowReport = (res) => (err, inputOptions) => { - const options = _.extendOwn(inputOptions || {}, { err }); + const options = { + ...inputOptions || {}, + err, + }; res.render("status", options); }; @@ -87,7 +90,10 @@ export const image = (req, res) => { const handle = (err, options) => { res.setHeader("Content-Type", "image/svg+xml"); - res.render("status-image", _.extend(options, getAdditionalOptions(err, options))); + res.render("status-image", { + ...options, + ...getAdditionalOptions(err, options), + }); }; parseOptionsFromReferer(parse(req.headers.referer || "").pathname || "", (err, options) => {