mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
refactor: adjust code to new TSLint rules
This commit is contained in:
23
src/cli.ts
23
src/cli.ts
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user