#!/usr/bin/env node
/**
* Pre-publish script
* Runs build and tests before publishing to npm
*/
const { execSync } = require('child_process');
console.log('Running pre-publish checks...');
// Build the project
console.log('\n1. Building...');
try {
execSync('npm run build', {
stdio: 'inherit',
});
} catch (error) {
console.error('Build failed. Aborting publish.');
process.exit(1);
}
// Run tests
console.log('\n2. Running tests...');
try {
execSync('npm test', {
stdio: 'inherit',
});
} catch (error) {
console.warn('Tests failed. Consider fixing before publishing.');
// Don't exit - allow publish to continue
}
// Run linting
console.log('\n3. Running linter...');
try {
execSync('npm run lint', {
stdio: 'inherit',
});
} catch (error) {
console.warn('Linting failed. Consider fixing before publishing.');
}
console.log('\nPre-publish checks completed!');