UNPKG

actionhero

Version:

actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks

29 lines (28 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sourceRelativeLinkPath = void 0; const fs = require("fs"); const path = require("path"); function sourceRelativeLinkPath(linkfile, pluginPaths) { const type = fs.readFileSync(linkfile).toString(); const pathParts = linkfile.split(path.sep); const name = pathParts[pathParts.length - 1].split(".")[0]; const pathsToTry = pluginPaths.slice(0); let pluginRoot; pathsToTry.forEach((pluginPath) => { const pluginPathAttempt = path.normalize(pluginPath + path.sep + name); try { const stats = fs.lstatSync(pluginPathAttempt); if (!pluginRoot && (stats.isDirectory() || stats.isSymbolicLink())) { pluginRoot = pluginPathAttempt; } } catch (e) { } }); if (!pluginRoot) { return false; } const pluginSection = path.normalize(pluginRoot + path.sep + type); return pluginSection; } exports.sourceRelativeLinkPath = sourceRelativeLinkPath;