mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-29 12:46:32 +03:00
move compile-testcases to src folder
This commit is contained in:
parent
d61069a30a
commit
9f1633e15e
@ -1,13 +0,0 @@
|
||||
import { compile } from 'node-elm-compiler';
|
||||
|
||||
// - Compile examples in `testcases/*` folder as js
|
||||
// Run whatever transformations we want on them, saving steps as `elm.{transformation}.js`
|
||||
compile(['Main.elm'], {
|
||||
output: 'output/elm.js',
|
||||
cwd: 'testcases/simple',
|
||||
});
|
||||
compile(['Main.elm'], {
|
||||
output: 'output/elm.opt.js',
|
||||
cwd: 'testcases/simple',
|
||||
optimize: true,
|
||||
});
|
30
src/compile-testcases.ts
Normal file
30
src/compile-testcases.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { compile } from 'node-elm-compiler';
|
||||
import Parser from 'tree-sitter';
|
||||
import Elm from 'tree-sitter-elm';
|
||||
import * as fs from 'fs';
|
||||
// Compile examples in `testcases/*` folder as js
|
||||
// Run whatever transformations we want on them, saving steps as `elm.{transformation}.js`
|
||||
compile(['Main.elm'], {
|
||||
output: 'output/elm.js',
|
||||
cwd: 'testcases/simple',
|
||||
});
|
||||
compile(['Main.elm'], {
|
||||
output: 'output/elm.opt.js',
|
||||
cwd: 'testcases/simple',
|
||||
optimize: true,
|
||||
});
|
||||
|
||||
// Parse the elm file using tree sitter
|
||||
const elmParser = new Parser();
|
||||
elmParser.setLanguage(Elm);
|
||||
|
||||
const parseElm = (filename: string) => {
|
||||
const source = fs.readFileSync(filename, 'utf8');
|
||||
console.log(source);
|
||||
const tree = elmParser.parse(source);
|
||||
console.log(tree);
|
||||
};
|
||||
|
||||
const result = parseElm('./testcases/simple/Main.elm');
|
||||
|
||||
console.log(result);
|
Loading…
Reference in New Issue
Block a user