Documentation Index
Fetch the complete documentation index at: https://docs.scanoss.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, ensure you have:
Installation
Import Styles
The package supports both ES module and CommonJS import styles:
// ES module
import { Scanner, ScannerEvents, ScannerCfg } from "scanoss";
// CommonJS
const { Scanner, ScannerEvents, ScannerCfg } = require("scanoss");
Quick Start
The following example runs a scan using the default SCANOSS configuration:
// Import the SCANOSS SDK using ES module syntax
import { Scanner, ScannerEvents } from "scanoss";
const scanner = new Scanner();
// Set the directory where scan results and fingerprints will be stored.
// If not set, the SDK will create a temporary folder with a timestamped name.
scanner.setWorkDirectory("/yourProjectFolder/ScanResults/");
// Triggered when the scan completes successfully
scanner.on(ScannerEvents.SCAN_DONE, (resultPath) => {
console.log("Scan complete. Results at:", resultPath);
});
// Outputs internal scanner log messages
scanner.on(ScannerEvents.SCANNER_LOG, (msg) => {
console.log(msg);
});
// Define the list of files to scan
const scannerInput = {
fileList: ["/yourProjectFolder/example1.c", "/yourProjectFolder/example2.c"],
};
// Start the scan.
// scanner.scan() returns a Promise and can be awaited,
// in addition to being observable via events.
await scanner.scan([scannerInput]);