fix: use passed method instead of resetting it

This commit is contained in:
Karl-Philipp Wulfert
2020-01-08 16:32:24 +01:00
parent 07b8d2aabf
commit db5645732c
2 changed files with 7 additions and 3 deletions

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {Logger} from '@openstapps/logger'; import {Logger} from '@openstapps/logger';
import * as request from 'request-promise-native'; import request from 'request-promise-native';
import { import {
AccessLevel, AccessLevel,
Branch, Branch,
@@ -472,7 +472,7 @@ export class Api {
...options, ...options,
}; };
if (['DELETE', 'GET', 'POST', 'PUT'].includes(_options.method)) { if (!['DELETE', 'GET', 'POST', 'PUT'].includes(_options.method)) {
_options.method = 'GET'; _options.method = 'GET';
} }

View File

@@ -16,7 +16,7 @@ import {asyncPool} from '@krlwlfrt/async-pool';
import {Logger} from '@openstapps/logger'; import {Logger} from '@openstapps/logger';
import {AddLogLevel} from '@openstapps/logger/lib/transformations/add-log-level'; import {AddLogLevel} from '@openstapps/logger/lib/transformations/add-log-level';
import {Colorize} from '@openstapps/logger/lib/transformations/colorize'; import {Colorize} from '@openstapps/logger/lib/transformations/colorize';
import * as commander from 'commander'; import {Command} from 'commander';
import {readFileSync} from 'fs'; import {readFileSync} from 'fs';
import {join} from 'path'; import {join} from 'path';
import {Api, ApiRequestOptions} from './api'; import {Api, ApiRequestOptions} from './api';
@@ -30,6 +30,8 @@ Logger.setTransformations([
const pkgJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json')) const pkgJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'))
.toString()); .toString());
const commander = new Command('openstapps-gitlab-api');
commander commander
.version(pkgJson.version); .version(pkgJson.version);
@@ -77,6 +79,8 @@ commander
// tslint:disable-next-line:no-magic-numbers // tslint:disable-next-line:no-magic-numbers
await asyncPool(5, issues, async (issue) => { await asyncPool(5, issues, async (issue) => {
if (action === 'close') { if (action === 'close') {
Logger.info(`Closing issue #${issue.iid} of project '${projectId}': ${issue.title}.`);
await api.makeGitLabAPIRequest(`/projects/${projectId}/issues/${issue.iid}`, { await api.makeGitLabAPIRequest(`/projects/${projectId}/issues/${issue.iid}`, {
data: { data: {
state_event: 'close', state_event: 'close',