diff --git a/package-lock.json b/package-lock.json index 0219e3a..adc2f8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1324,6 +1324,12 @@ "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==" }, + "@types/object-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/object-hash/-/object-hash-1.2.0.tgz", + "integrity": "sha512-0JKYQRatHdzijO/ni7JV5eHUJWaMRpGvwiABk8U5iAk5Corm0yLNEfYGNkZWYc+wCyCKKpg0+TsZIvP8AymIYA==", + "dev": true + }, "@types/pify": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/pify/-/pify-3.0.2.tgz", diff --git a/package.json b/package.json index d2fa91a..4975b4c 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/core/options.ts b/src/core/options.ts index 628d616..dfab483 100644 --- a/src/core/options.ts +++ b/src/core/options.ts @@ -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: { @@ -15,7 +15,7 @@ export const state = { scope: {} as IScopeOptions }; -let id = uuid(); +let id = 'INIT'; let options: TCoreOptions = {}; merge(); @@ -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) @@ -51,4 +48,7 @@ function merge(): void { // Set logging level if (options.log) setLevel(options.log); + + // Set id to object hash + id = hash(options); }