Skip to content

Commit

Permalink
move config search to new config-service
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Aug 12, 2018
1 parent a343886 commit ded1b07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
19 changes: 2 additions & 17 deletions server/artifactory-service.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
const axios = require("axios");
const path = require("path");
const homedir = require("os").homedir();
const configFile = process.env.MOCK
? ".sample.npmfrogrc.json"
: ".npmfrogrc.json";
let config;

try {
config = require(path.join(__dirname, "..", configFile));
} catch(er1) {
try {
config = require(path.join(homedir, configFile));
} catch(er2) {
console.log('No config file found. Please create a config file as described in the README.md file or set environment variable MOCK=true to test the UI.');
}
}
const config = require('./config-service.js');
const repoKey = config.artifactory.repoKey;

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
axios.defaults.baseURL = `${config.artifactory.baseURL}/artifactory/api/npm/`;
axios.defaults.headers.common["Authorization"] = config.artifactory.apiKey;

const repoKey = config.artifactory.repoKey;

module.exports = {
fetchPackages: async () => {
if (process.env.MOCK) {
Expand Down
19 changes: 19 additions & 0 deletions server/config-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require("path");
const homedir = require("os").homedir();

const configFile = process.env.MOCK
? ".sample.npmfrogrc.json"
: ".npmfrogrc.json";
let config;

try {
config = require(path.join(__dirname, "..", configFile));
} catch(er1) {
try {
config = require(path.join(homedir, configFile));
} catch(er2) {
console.log('No config file found. Please create a config file as described in the README.md file or set environment variable MOCK=true to test the UI.');
}
}

module.exports = config;

0 comments on commit ded1b07

Please sign in to comment.