X-Git-Url: http://git.squeep.com/?p=squeep-indieauth-helper;a=blobdiff_plain;f=lib%2Fcommon.js;fp=lib%2Fcommon.js;h=3bf7e55cc7e85a4cd050fd2708dc2726fa9f9d94;hp=f199b4947ed1ba537a29350c617322cf64678512;hb=3d41f4dd33d59d0c11c97ddeb51ab22d851b93e6;hpb=322b4e9de706d50a0eff6596e414f635c62deb54 diff --git a/lib/common.js b/lib/common.js index f199b49..3bf7e55 100644 --- a/lib/common.js +++ b/lib/common.js @@ -1,17 +1,18 @@ 'use strict'; const path = require('path'); +const { name: packageName, version: packageVersion } = require('../package'); + +const libraryIdentifier = `${packageName}@${packageVersion}`; /** * Return a function which combines a part of the filename with a scope, for use in logging. * @param {string} filename */ const fileScope = (filename) => { - let fScope = path.basename(filename, '.js'); - if (fScope === 'index') { - fScope = path.basename(path.dirname(filename)); - } - return (scope) => `${fScope}:${scope}`; + const shortFilename = path.basename(filename, '.js'); + const fScope = (shortFilename === 'index') ? path.basename(path.dirname(filename)) : shortFilename; + return (scope) => [libraryIdentifier, fScope, scope].join(':'); }