forked from Lorenzobattistela/agda-check
-
Notifications
You must be signed in to change notification settings - Fork 1
/
agda-compile.js
executable file
·30 lines (24 loc) · 977 Bytes
/
agda-compile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const agdaFile = process.argv[2];
if (!agdaFile || !agdaFile.endsWith('.agda')) {
console.error('Usage: agda-compile <agda-file.agda>');
console.error('Please provide an Agda file (.agda) as an argument.');
process.exit(1);
}
const baseName = path.basename(agdaFile, '.agda');
try {
// Compile Agda to executable
console.log('Compiling Agda file...');
execSync(`agda --compile --no-libraries --no-termination-check ${agdaFile}`, { stdio: 'inherit' });
// Remove MAlonzo directory
console.log('Removing MAlonzo directory...');
fs.rmSync('MAlonzo', { recursive: true, force: true });
console.log(`Successfully compiled ${agdaFile} to ${baseName}`);
console.log(`You can now run the executable with: ./${baseName}`);
} catch (error) {
console.error('An error occurred during compilation:', error.message);
process.exit(1);
}