Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 67x 7x 7x 1x 6x 6x 6x 10x 10x 10x 7x 7x 2x 2x 2x 1x 1x | "use strict";
const path = require("path");
function getBasePath(options) {
return (
options.moduleName && options.moduleName.basePath ||
options.basePath
);
}
function generateModuleName(meta) {
const customModuleName = extractCustomModuleName(meta);
if ( customModuleName ) {
return customModuleName;
}
const basePath = getBasePath(meta.opts || {});
const moduleName = toBasePath(basePath, meta.filename);
return moduleName;
}
function toBasePath(basePath, filePath) {
const relativePath = path.relative(basePath, filePath);
const fullPath = relativePath
.replace(/\.(js|ts)$/, "")
.replace(/\\/g, "/");
return fullPath;
}
function extractCustomModuleName(meta) {
// try find comment:
// module name: some
let sourceCode = meta.file.code;
if ( /\/\/\s*module name\s*:/.test(sourceCode) ) {
let execRes = /\/\/\s*module name\s*:[ \t]*([^ \t\n\r]+)/.exec(sourceCode);
const customModuleName = execRes && execRes[1];
if ( customModuleName ) {
return customModuleName.trim();
}
}
}
module.exports = {
getBasePath,
generateModuleName,
toBasePath
}; |