temporal-db
Version:
Git-like versioning for application data
59 lines (49 loc) • 1.75 kB
JavaScript
const fs = require('fs');
const path = require('path');
// Make CLI file executable in a cross-platform way
const cliPath = path.join(__dirname, '..', 'examples', 'cli.js');
if (fs.existsSync(cliPath)) {
try {
// Add shebang if it doesn't exist
let content = fs.readFileSync(cliPath, 'utf8');
if (!content.startsWith('#!/usr/bin/env node')) {
content = '#!/usr/bin/env node\n' + content;
fs.writeFileSync(cliPath, content);
}
// On Unix-like systems, make the file executable
if (process.platform !== 'win32') {
fs.chmodSync(cliPath, '755');
}
console.log('CLI file prepared successfully');
} catch (error) {
console.error('Error preparing CLI file:', error);
process.exit(1);
}
} else {
console.warn('CLI file not found at', cliPath);
// Create a minimal CLI file
const minimalCliContent = `#!/usr/bin/env node
/**
* CLI interface for TemporalDB
*/
console.log('TemporalDB CLI - Minimal implementation');
console.log('For full CLI functionality, please refer to the documentation.');
`;
try {
// Create the examples directory if it doesn't exist
const examplesDir = path.join(__dirname, '..', 'examples');
if (!fs.existsSync(examplesDir)) {
fs.mkdirSync(examplesDir, { recursive: true });
}
// Write the minimal CLI file
fs.writeFileSync(cliPath, minimalCliContent);
console.log('Created minimal CLI file');
// On Unix-like systems, make the file executable
if (process.platform !== 'win32') {
fs.chmodSync(cliPath, '755');
}
} catch (error) {
console.error('Error creating minimal CLI file:', error);
process.exit(1);
}
}