@increff/load-runner-k6
Version: 
A powerful CLI wrapper around k6 for load testing with JSON configuration, variable substitution, custom ramping patterns, and comprehensive logging
43 lines (35 loc) • 1.08 kB
JavaScript
// Main entry point for the load-runner npm package
const { spawn } = require('child_process');
const path = require('path');
// Export the main functionality
module.exports = {
  // Run the load-runner CLI
  run: (args = []) => {
    const loadRunnerPath = path.join(__dirname, 'bin', 'load-runner.js');
    const child = spawn('node', [loadRunnerPath, ...args], {
      stdio: 'inherit',
      cwd: process.cwd()
    });
    
    return new Promise((resolve, reject) => {
      child.on('close', (code) => {
        if (code === 0) {
          resolve(code);
        } else {
          reject(new Error(`load-runner exited with code ${code}`));
        }
      });
      
      child.on('error', (error) => {
        reject(error);
      });
    });
  },
  
  // Get the path to the load-runner binary
  getPath: () => path.join(__dirname, 'bin', 'load-runner.js'),
  
  // Version info
  version: require('./package.json').version
};
// If this file is run directly, execute the CLI
if (require.main === module) {
  require('./bin/load-runner.js');
}