initial commit
[squeep-chores] / lib / common.js
1 'use strict';
2
3 const path = require('path');
4 const { name: packageName, version: packageVersion } = require('../package');
5
6 const libraryIdentifier = `${packageName}@${packageVersion}`;
7
8 /**
9 * Return a function for decorating logging method scopes.
10 * @param {String} filename
11 */
12 const fileScope = (filename) => {
13 const shortFilename = path.basename(filename, '.js');
14 const fScope = (shortFilename === 'index') ? path.basename(path.dirname(filename)) : shortFilename;
15 return (scope) => [libraryIdentifier, fScope, scope].join(':');
16 };
17
18 module.exports = {
19 fileScope,
20 };