From d17c31d725e411754e9e2addba615a40fb652ea1 Mon Sep 17 00:00:00 2001 From: Varij Kapil Date: Wed, 3 Oct 2018 21:44:59 +0200 Subject: [PATCH] refactor: restructure Utils import (#1041) --- src/api/web/index.js | 4 ++-- src/lib/cli.js | 4 ++-- src/lib/logger.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/web/index.js b/src/api/web/index.js index 8cc338d58..c19697879 100644 --- a/src/api/web/index.js +++ b/src/api/web/index.js @@ -9,7 +9,7 @@ import VError from 'verror'; import chalk from 'chalk'; import express from 'express'; -import * as Utils from '../../lib/utils'; +import { combineBaseUrl, getWebProtocol } from '../../lib/utils'; import Search from '../../lib/search'; import { HEADERS, HTTP_STATUS, WEB_TITLE } from '../../lib/constants'; @@ -60,7 +60,7 @@ module.exports = function(config, auth, storage) { }); router.get('/', function(req, res) { - const base = Utils.combineBaseUrl(Utils.getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol), req.get('host'), config.url_prefix); + const base = combineBaseUrl(getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol), req.get('host'), config.url_prefix); let webPage = template .replace(/ToReplaceByVerdaccio/g, base) diff --git a/src/lib/cli.js b/src/lib/cli.js index 66ae23b08..328cdebf1 100644 --- a/src/lib/cli.js +++ b/src/lib/cli.js @@ -12,6 +12,7 @@ import chalk from 'chalk'; import {startVerdaccio, listenDefaultCallback} from './bootstrap'; import findConfigFile from './config-path'; import {verdaccioUpdateBanner} from './update-banner'; +import { parseConfigFile } from './utils'; if (process.getuid && process.getuid() === 0) { global.console.warn(chalk.bgYellow('Verdaccio doesn\'t need superuser privileges. Don\'t run it under root.')); @@ -30,7 +31,6 @@ const logger = require('./logger'); logger.setup(); // default setup const commander = require('commander'); -const Utils = require('./utils'); const pkginfo = require('pkginfo')(module); // eslint-disable-line no-unused-vars const pkgVersion = module.exports.version; const pkgName = module.exports.name; @@ -60,7 +60,7 @@ const cliListener = commander.listen; try { configPathLocation = findConfigFile(commander.config); - verdaccioConfiguration = Utils.parseConfigFile(configPathLocation); + verdaccioConfiguration = parseConfigFile(configPathLocation); process.title = verdaccioConfiguration.web && verdaccioConfiguration.web.title || 'verdaccio'; if (!verdaccioConfiguration.self_path) { diff --git a/src/lib/logger.js b/src/lib/logger.js index 981a478c2..616fff40e 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -1,13 +1,13 @@ /** * @prettier */ +import { isObject } from './utils'; const cluster = require('cluster'); const Logger = require('bunyan'); const Error = require('http-errors'); const Stream = require('stream'); const chalk = require('chalk'); -const Utils = require('./utils'); const pkgJSON = require('../../package.json'); const _ = require('lodash'); const { format } = require('date-fns'); @@ -195,7 +195,7 @@ function fillInMsgTemplate(msg, obj, colors) { let _ref = name.split('.'); for (let _i = 0; _i < _ref.length; _i++) { let id = _ref[_i]; - if (Utils.isObject(str) || Array.isArray(str)) { + if (isObject(str) || Array.isArray(str)) { str = str[id]; } else { str = undefined;