UNPKG

@alu0101051420/constant-folding

Version:
47 lines (42 loc) 1.11 kB
#!/usr/bin/env node const { program } = require('commander'); const fs = require('fs'); const { version, description } = require('../package.json'); const eggConstantFolding = require('../src/egg-constant-folding'); // Your libs "use strict"; program .version(version) .name('blah') .arguments("<filename>") .description(description, { filename: 'file with the original code' }) .action((filename, options) => { return transpile(filename, options.output); }); program.parse(process.argv); /** * A function that takes two file names and blah, * ... * ... * @param {string} input_file The file from which to read the code * @param {string} output_file The file to which to write the code with the logs * etc. * @private */ function transpile(input_file) { try { fs.readFile(input_file, 'utf-8', (err, input) => { if (err) { console.log("Couldn't read the file: " + err); return; } let result = eggConstantFolding(JSON.parse(input)); console.log(result); return result; }); } catch (err) { console.log(err); } }