Implement e2e tests

This commit is contained in:
Reinier Criel 2025-10-23 11:41:13 -07:00
parent f817bf887a
commit 059cba06bc
17 changed files with 163 additions and 293 deletions

View file

@ -1,5 +1,4 @@
import { commandArgumentScanner } from "./dependencyScanner/commandArgumentScanner.js";
import { nullScanner } from "./dependencyScanner/nullScanner.js";
import { runPip } from "./runPipCommand.js";
import {
getPipCommandForArgs,
@ -9,8 +8,7 @@ import {
} from "./utils/pipCommands.js";
/**
* Creates a package manager interface for Python's pip package installer
*
* Creates a package manager
* @param {string} [command="pip"] - The pip command to use (e.g., "pip", "pip3") defaults to "pip"
*/
export function createPipPackageManager(command = "pip") {
@ -41,15 +39,20 @@ const commandScannerMapping = {
[pipInstallCommand]: commandArgumentScanner(),
[pipDownloadCommand]: commandArgumentScanner(), // download also fetches packages from PyPI
[pipWheelCommand]: commandArgumentScanner(), // wheel downloads and builds packages
// Other commands (uninstall, list, etc.) will use nullScanner() by default
// Other commands return null scanner by default
};
const NULL_SCANNER = {
shouldScan: () => false,
scan: () => [],
};
function findDependencyScannerForCommand(scanners, args) {
const command = getPipCommandForArgs(args);
if (!command) {
return nullScanner();
return NULL_SCANNER;
}
const scanner = scanners[command];
return scanner ? scanner : nullScanner();
return scanner || NULL_SCANNER;
}