Got rid of _.extend

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent d63cdf06c5
commit 4346148207
  1. 10
      BuildServer/lib/commenter.ts
  2. 15
      BuildServer/lib/report-processor.ts
  3. 25
      BuildServer/lib/status-processor.ts
  4. 5
      BuildServer/lib/task-processor.ts
  5. 5
      BuildServer/lib/tasks/dotnetcompile.ts
  6. 5
      BuildServer/lib/tasks/dotnetnugetpack.ts
  7. 5
      BuildServer/lib/tasks/dotnetnugetpush.ts
  8. 5
      BuildServer/routes/manual.ts
  9. 10
      BuildServer/routes/status.ts

@ -147,8 +147,14 @@ const checkPullRequest = (options, callback) => {
}; };
export const commentOnPullRequest = (originalOptions, callback) => { export const commentOnPullRequest = (originalOptions, callback) => {
const optionsGithub = _.extend(originalOptions, { github: settings.createGithub(originalOptions.baseRepoOptions.owner) }); const optionsGithub = {
const options = _.extend(optionsGithub, { onTenthAttempt: () => writeComment(optionsGithub, "Waiting for build to finish...", _.noop) }); ...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) => { return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength) const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength)

@ -98,20 +98,27 @@ export const loadReport = (app, options, callback) => {
return readReport(releaseDir, (readErr, report) => { return readReport(releaseDir, (readErr, report) => {
if (readErr) { if (readErr) {
return callback(readErr, _.extend(options, { files })); return callback(readErr, {
...options,
files,
});
} }
return callback(null, _.extend(options, { return callback(null, {
...options,
files, files,
report, report,
})); });
}); });
}); });
}); });
}; };
export const getStatusMessageFromRelease = (app, originalOptions, callback) => { 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 releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
const reportFile = join(releaseDir, reportFilename); const reportFile = join(releaseDir, reportFilename);

@ -23,10 +23,11 @@ const addBranchInfo = (app, options, callback) => {
const branchParts = branch.split("/"); const branchParts = branch.split("/");
const branchName = branchParts[branchParts.length - 1]; const branchName = branchParts[branchParts.length - 1];
return callback(null, _.extend(options, { return callback(null, {
...options,
branch, branch,
branchName, branchName,
})); });
}); });
}); });
}; };
@ -46,7 +47,10 @@ const addRevInfo = (app, options, callback) => {
const rev = data.toString(); 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) { 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)) { 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"; const branchName = options.branchName || "master";
return addRevInfo(app, _.extend(result, { return addRevInfo(app, {
...result,
branch: `refs/heads/${branchName}`, branch: `refs/heads/${branchName}`,
branchName, branchName,
}), callback); }, callback);
}; };
export const getReport = (app, options, callback) => parseOptions(app, options, (err, result) => { export const getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {

@ -78,10 +78,11 @@ export const processTask = (task, context, callback) => {
}; };
const flags = {}; const flags = {};
const processor = createTaskProcessor(task, { const processor = createTaskProcessor(task, {
context: _.extend(context, { context: {
...context,
addFlag: addFlag(flags), addFlag: addFlag(flags),
containsFlag: containsFlag(flags), containsFlag: containsFlag(flags),
}), },
onError: messageProcessor(errors), onError: messageProcessor(errors),
onInfo: messageProcessor(infos), onInfo: messageProcessor(infos),
onWarn: messageProcessor(warns), onWarn: messageProcessor(warns),

@ -35,5 +35,8 @@ export default ((params, processor) => {
command: "compile", command: "compile",
}; };
return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor); return dotnetbuilderwrapper({
...compileParams,
...getAdditionalSigningParameters(),
}, processor);
}) as Task; }) as Task;

@ -5,9 +5,10 @@ import * as _ from "underscore";
import { Task } from "../../types"; import { Task } from "../../types";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { export default ((params, processor) => dotnetnugetprocessinternal({
...params,
getFinalTask: (nupkg) => ({ getFinalTask: (nupkg) => ({
params: { filename: nupkg }, params: { filename: nupkg },
type: "copy", type: "copy",
}), }),
}), processor)) as Task; }, processor)) as Task;

@ -5,9 +5,10 @@ import * as _ from "underscore";
import { Task } from "../../types"; import { Task } from "../../types";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { export default ((params, processor) => dotnetnugetprocessinternal({
...params,
getFinalTask: (nupkg) => ({ getFinalTask: (nupkg) => ({
params: { Package: nupkg }, params: { Package: nupkg },
type: "dotnetnugetpushonly", type: "dotnetnugetpushonly",
}), }),
}), processor)) as Task; }, processor)) as Task;

@ -6,10 +6,11 @@ import { build } from "../lib/builder";
export const get = (req, res) => res.render("manual"); export const get = (req, res) => res.render("manual");
export const post = (req, res) => { export const post = (req, res) => {
const options = _.extend(req.body, { const options = {
...req.body,
app: req.app, app: req.app,
url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`, url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`,
}); };
build(options, (err, result) => { build(options, (err, result) => {
console.log("Done processing manual request"); console.log("Done processing manual request");

@ -35,7 +35,10 @@ const parseOptionsFromReferer = (path, callback) => {
}; };
const createShowReport = (res) => (err, inputOptions) => { const createShowReport = (res) => (err, inputOptions) => {
const options = _.extendOwn(inputOptions || {}, { err }); const options = {
...inputOptions || {},
err,
};
res.render("status", options); res.render("status", options);
}; };
@ -87,7 +90,10 @@ export const image = (req, res) => {
const handle = (err, options) => { const handle = (err, options) => {
res.setHeader("Content-Type", "image/svg+xml"); 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) => { parseOptionsFromReferer(parse(req.headers.referer || "").pathname || "", (err, options) => {

Loading…
Cancel
Save