Skip to content

Commit

Permalink
refactor: a conf.js működés függvénybe szervezése
Browse files Browse the repository at this point in the history
  • Loading branch information
juzraai committed Oct 18, 2019
1 parent 99dbdeb commit 47eb565
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
27 changes: 16 additions & 11 deletions src/conf.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
const dotenv = require('dotenv');
const cli = require('./cli');

// Load environment variables and defaults
dotenv.config();
process.env.LOG_LEVEL = 2;
process.env.OUTPUT_DIR = process.env.OUTPUT_DIR || './szamlak';
process.env.SLEEP = process.env.SLEEP || 3;
process.env.TEMP_DIR = process.env.TEMP_DIR || '';
function configurate() {
// Load environment variables and defaults
dotenv.config();
process.env.LOG_LEVEL = 2;
process.env.OUTPUT_DIR = process.env.OUTPUT_DIR || './szamlak';
process.env.SLEEP = process.env.SLEEP || 3;
process.env.TEMP_DIR = process.env.TEMP_DIR || '';

// Load command line arguments
cli.config();
// Load command line arguments
cli.config();

// Auto print help
if (!process.env.DIJNET_USER || !process.env.DIJNET_PASS) {
cli.printHelpAndExit();
}

// Auto print help
if (!process.env.DIJNET_USER || !process.env.DIJNET_PASS) {
cli.printHelpAndExit();
}

module.exports = configurate;
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const fs = require('fs');
const path = require('path');
const mkdirp = require('util').promisify(require('mkdirp'));
require('./conf'); // eslint-disable-line import/no-unassigned-import
const configurate = require('./conf');
const { handleError } = require('./err');
const dijnet = require('./lib');
const log = require('./logger');

configurate();

function tmp(name) {
return process.env.TEMP_DIR.length === 0 ? null : path.join(process.env.TEMP_DIR, name);
}
Expand Down

0 comments on commit 47eb565

Please sign in to comment.