refactor: adjust code to new TSLint rules

This commit is contained in:
Karl-Philipp Wulfert
2019-11-19 12:06:54 +01:00
parent 8a9ab5c041
commit edca51be10
3 changed files with 113 additions and 108 deletions

View File

@@ -12,12 +12,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import * as commander from 'commander';
import {readFileSync} from 'fs';
import {join} from 'path';
import {Api, ApiRequestOptions, logger} from './api';
import {Api, ApiRequestOptions} from './api';
const pkgJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json')).toString());
const pkgJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'))
.toString());
commander
.version(pkgJson.version);
@@ -38,7 +40,7 @@ if (typeof commander.call === 'undefined') {
if (typeof commander.token === 'undefined') {
if (typeof process.env.GITLAB_PRIVATE_TOKEN === 'undefined') {
logger.error('You have to supply ');
Logger.warn('You probably want to supply a GitLab token either via option or environment variable (GITLAB_PRIVATE_TOKEN).');
}
commander.token = process.env.GITLAB_PRIVATE_TOKEN;
@@ -56,10 +58,11 @@ if (typeof commander.data !== 'undefined') {
options.data = JSON.parse(commander.data);
}
gitLabApi.makeGitLabAPIRequest(commander.call, options).then((result) => {
logger.ok(result);
process.exit(1);
}, (err) => {
logger.error(err);
process.exit(1);
});
gitLabApi.makeGitLabAPIRequest(commander.call, options)
.then((result) => {
Logger.ok(result);
process.exit(1);
}, async (err) => {
await Logger.error(err);
process.exit(1);
});