A command line tool to help build, run, and test web extensions
—
Core programmatic interface for web-ext providing access to CLI functionality and individual commands.
Primary function for running web-ext programmatically, equivalent to using the CLI.
/**
* Main entry point for web-ext CLI functionality
* @param absolutePackageDir - Absolute path to the package directory
* @param options - Optional configuration for execution
* @returns Promise that resolves when execution completes
*/
function main(absolutePackageDir: string, options?: MainOptions): Promise<void>;
interface MainOptions {
getVersion?: (absolutePackageDir: string) => Promise<string>;
commands?: CommandsObject;
argv?: string[];
runOptions?: RunOptions;
}Usage Example:
import webExt from "web-ext";
// Run with default settings (uses process.argv)
await webExt.main(process.cwd());
// Run with custom arguments
await webExt.main('/path/to/extension', {
argv: ['build', '--source-dir', './src']
});Direct access to individual command implementations without CLI argument parsing.
interface CommandsObject {
build: (params: BuildParams, options?: BuildOptions) => Promise<BuildResult>;
run: (params: RunParams, options?: RunOptions) => Promise<void>;
lint: (params: LintParams, options?: LintOptions) => Promise<void>;
sign: (params: SignParams, options?: SignOptions) => Promise<SignResult>;
docs: (params: DocsParams, options?: DocsOptions) => Promise<void>;
dumpConfig: (params: DumpConfigParams, options?: DumpConfigOptions) => Promise<void>;
}Usage Example:
import { cmd } from "web-ext";
// Build extension
const result = await cmd.build({
sourceDir: './my-extension',
artifactsDir: './web-ext-artifacts',
overwriteDest: true
});
console.log('Extension built at:', result.extensionPath);
// Run extension in Firefox
await cmd.run({
sourceDir: './my-extension',
target: ['firefox-desktop'],
firefox: 'firefox',
startUrl: ['https://example.com']
});interface RunOptions {
shouldExitProgram?: boolean;
checkForUpdates?: Function;
systemProcess?: NodeJS.Process;
logStream?: any;
}
interface BuildResult {
extensionPath: string;
}
interface SignResult {
success: boolean;
id?: string;
downloadedFiles?: string[];
}Install with Tessl CLI
npx tessl i tessl/npm-web-ext