Remove binary related things from index.js, start execution from bin.js

This commit is contained in:
Jeroen Engels 2021-10-01 18:35:15 +02:00
parent aca18d1433
commit 84e9c0f95d
2 changed files with 36 additions and 72 deletions

View File

@ -1,11 +1,6 @@
// tslint:disable-next-line no-require-imports no-var-requires
import program from 'commander';
import * as path from 'path';
import * as Transform from './transform';
import { toolDefaults } from './types';
import { compileToStringSync } from 'node-elm-compiler';
import * as fs from 'fs';
import chalk from 'chalk';
import { run } from './index';
const { version } = require('../package.json');
// import * as BenchInit from './benchmark/init'
// import * as Benchmark from './benchmark/benchmark';
@ -33,9 +28,8 @@ Give me an Elm file, I'll compile it behind the scenes using Elm 0.19.1, and the
.parse(process.argv);
const { output, optimizeSpeed } = program.opts();
console.log(program.opts());
// run({
// inputFilePath: program.args[0],
// outputFilePath: output,
// optimizeSpeed
// }).catch((e) => console.error(e));
run({
inputFilePath: program.args[0],
outputFilePath: output,
optimizeSpeed
}).catch((e) => console.error(e));

View File

@ -5,33 +5,10 @@ import * as Transform from './transform';
import { toolDefaults } from './types';
import { compileToStringSync } from 'node-elm-compiler';
import * as fs from 'fs';
import chalk from 'chalk';
const { version } = require('../package.json');
// import * as BenchInit from './benchmark/init'
// import * as Benchmark from './benchmark/benchmark';
// import * as Reporting from './benchmark/reporting';
program
.version(version)
.description(
`${chalk.yellow('Elm Optimize Level 2!')}
This applies a second level of optimization to the javascript that Elm creates.
Make sure you're familiar with Elm's built-in optimization first: ${chalk.cyan(
'https://guide.elm-lang.org/optimization/asset_size.html'
)}
Give me an Elm file, I'll compile it behind the scenes using Elm 0.19.1, and then I'll make some more optimizations!`
)
.usage('[options] <src/Main.elm>')
.option('--output <output>', 'the javascript file to create.', 'elm.js')
.option('-O3, --optimize-speed', 'Enable optimizations that likely increases asset size', false)
// .option('--init-benchmark <dir>', 'Generate some files to help run benchmarks')
// .option('--benchmark <dir>', 'Run the benchmark in the given directory.')
// .option('--replacements <dir>', 'Replace stuff')
.parse(process.argv);
export async function run(options: {
inputFilePath: string | undefined,
outputFilePath: string | null,
@ -140,10 +117,3 @@ async function runWithLogger(
log('');
}
}
const { output, optimizeSpeed } = program.opts();
run({
inputFilePath: program.args[0],
outputFilePath: output,
optimizeSpeed
}).catch((e) => console.error(e));