Skip to content

Commit

Permalink
feat(core/options): uses object hash to identify options
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 25, 2019
1 parent 492c737 commit fcd9122
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@types/jest": "^24.0.11",
"@types/js-yaml": "^3.12.1",
"@types/lodash.mergewith": "^4.6.6",
"@types/object-hash": "^1.2.0",
"@types/pify": "^3.0.2",
"@types/signal-exit": "^3.0.0",
"@types/uuid": "^3.4.4",
Expand Down Expand Up @@ -125,6 +126,7 @@
"lodash.mergewith": "^4.6.1",
"loglevel": "^1.6.1",
"manage-path": "^2.0.0",
"object-hash": "^1.3.1",
"pify": "^4.0.1",
"promist": "^0.5.3",
"signal-exit": "^3.0.2",
Expand Down
10 changes: 5 additions & 5 deletions src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mergewith from 'lodash.mergewith';
import { IBaseOptions, IScopeOptions, TCoreOptions } from '~/types';
import { DEFAULT_LOG_LEVEL } from '~/constants';
import { setLevel } from '~/utils/logger';
import uuid from 'uuid/v4';
import hash from 'object-hash';

export const state = {
base: {
Expand All @@ -15,7 +15,7 @@ export const state = {
scope: {} as IScopeOptions
};

let id = uuid();
let id = 'INIT';
let options: TCoreOptions = {};
merge();

Expand All @@ -37,9 +37,6 @@ export default {
};

function merge(): void {
// reset id
id = uuid();

// merge base and scope
options = Object.assign({}, state.base, state.scope, {
env: Object.assign({}, state.base.env, state.scope.env)
Expand All @@ -51,4 +48,7 @@ function merge(): void {

// Set logging level
if (options.log) setLevel(options.log);

// Set id to object hash
id = hash(options);
}

0 comments on commit fcd9122

Please sign in to comment.