Skip to content

Commit

Permalink
v1.6.1 Changes (#117)
Browse files Browse the repository at this point in the history
* Add Changes

* No Need for Other Environment Variables

* Handle No Hostname Case

* Hostname Modifications

* Smallest Change

* Expanded inside Waterfall

* It's risky to return functions
  • Loading branch information
smusali authored Jul 19, 2019
1 parent 3090509 commit b0826bc
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 240 deletions.
445 changes: 229 additions & 216 deletions index.js

Large diffs are not rendered by default.

19 changes: 1 addition & 18 deletions lib/file-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const debug = require('debug')('logdna:lib:file-utilities');
const fs = require('fs');
const glob = require('glob');
const os = require('os');
const properties = require('properties');
const spawn = require('child_process').spawn;

// Internal Modules
Expand Down Expand Up @@ -261,21 +260,7 @@ const streamAllLogs = (config, callback) => {
}
};

const saveConfig = (config, configPath, callback) => {
return properties.stringify(config, {
path: configPath
}, callback);
};

// Custom Appender:
const appender = (xs) => {
xs = xs || [];
return (x) => {
xs.push(x);
return xs;
};
};

// Gracefully Shutting Down
const gracefulShutdown = (signal) => {
log('Got ' + signal + ' signal, shutting down...');
setTimeout(() => {
Expand All @@ -295,8 +280,6 @@ process.once('SIGINT', () => { gracefulShutdown('SIGINT'); }); // ctrl+c
// Module Exports
module.exports.files = files;
module.exports.gracefulShutdown = gracefulShutdown;
module.exports.appender = appender;
module.exports.saveConfig = saveConfig;
module.exports.getFiles = getFiles;
module.exports.streamFiles = streamFiles;
module.exports.streamAllLogs = streamAllLogs;
21 changes: 20 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// External Modules
const os = require('os');
const properties = require('properties');
const spawn = require('child_process').spawn;

// Custom Splitter:
Expand All @@ -15,7 +16,7 @@ const split = (str, delimiter, hasWhitespace) => {
};

// Prepare Message Reporting the Options Affected:
const preparePostMessage = diff => {
const preparePostMessage = (diff) => {
const length = diff.length;
if (length === 0) return 'Nothing has';
if (length === 1) return `${diff[0]} has`;
Expand Down Expand Up @@ -165,10 +166,28 @@ const restartSelf = () => {
}
};

// Saving into Config Files
const saveConfig = (config, configPath, callback) => {
return properties.stringify(config, {
path: configPath
}, callback);
};

// Custom Appender
const appender = (xs) => {
xs = xs || [];
return (x) => {
xs.push(x);
return xs;
};
};

exports.unsetConfig = unsetConfig;
exports.processOption = processOption;
exports.stringify = stringify;
exports.split = split;
exports.pick2list = pick2list;
exports.updateSelf = updateSelf;
exports.restartSelf = restartSelf;
exports.saveConfig = saveConfig;
exports.appender = appender;
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 10 additions & 5 deletions test/lib/file-utilities.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
/* globals describe, it, beforeEach, after */

// Constants
// External Modules
const assert = require('assert');
const async = require('async');
const configPath = './test/assets/testconfig.config';
const debug = require('debug')('logdna:test:lib:file-utilities');
const fileUtilities = require('../../lib/file-utilities');
const fs = require('fs');
const path = require('path');
const properties = require('properties');
const rimraf = require('rimraf');

// Internal Modules
const fileUtilities = require('../../lib/file-utilities');
const utils = require('../../lib/utils');

// Constants
const configPath = './test/assets/testconfig.config';
const tempDir = '.temp';

describe('lib:file-utilities', () => {
Expand Down Expand Up @@ -103,7 +108,7 @@ describe('lib:file-utilities', () => {

describe('#appender()', () => {
it('provides an appender that appends to end of array', () => {
const func = fileUtilities.appender();
const func = utils.appender();

func('x');
func('y');
Expand All @@ -123,7 +128,7 @@ describe('lib:file-utilities', () => {
path: true
}, cb);
}, (config, cb) => {
return fileUtilities.saveConfig(config, path.join(tempDir, 'test.config'), cb);
return utils.saveConfig(config, path.join(tempDir, 'test.config'), cb);
}, (success, cb) => {
return properties.parse(configPath, {
path: true
Expand Down
6 changes: 6 additions & 0 deletions test/lib/os-version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/* globals describe, it, before, after */

// External Modules
const assert = require('assert');
const debug = require('debug')('logdna:test:lib:os-version');

// Internal Modules
const osVersion = require('../../lib/os-version');

// Constants
const testConfig = '../assets/test-os-version.config';

describe('lib:os-version', () => {
Expand Down

0 comments on commit b0826bc

Please sign in to comment.