UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

40 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FlowrAnalyzerVirtualEnvFilePlugin = void 0; const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin"); const semver_1 = require("semver"); const flowr_file_1 = require("../../context/flowr-file"); const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source"); /** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`, `uvr.lock`, `packrat.lock`). */ const VirtualEnvFilePattern = /^(renv|rv|uvr|packrat)\.lock$/i; /** * Tags a project's virtual-environment lockfiles with the {@link FileRole.VirtualEnv} role, so the version * plugins that read them can look them up by role instead of scanning every project file. */ class FlowrAnalyzerVirtualEnvFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin { name = 'flowr-analyzer-virtualenv-files-plugin'; description = 'Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock).'; version = new semver_1.SemVer('0.1.0'); pathPattern; /** * Creates a new instance of the virtual-environment file plugin. * @param pathPattern - The pattern to identify lockfiles, see {@link VirtualEnvFilePattern} for the default. */ constructor(pathPattern = VirtualEnvFilePattern) { super(); this.pathPattern = pathPattern; } applies(file) { return this.pathPattern.test((0, built_in_source_1.platformBasename)(file.toString())); } /** * Processes the given file, assigning it the {@link FileRole.VirtualEnv} role. The file may still be * relevant to other plugins, so this returns the `true` flag to keep the loader chain going. */ process(_ctx, file) { file.assignRole(flowr_file_1.FileRole.VirtualEnv); return [file, true]; } } exports.FlowrAnalyzerVirtualEnvFilePlugin = FlowrAnalyzerVirtualEnvFilePlugin; //# sourceMappingURL=flowr-analyzer-virtualenv-file-plugin.js.map