2021-05-02 17:42:04 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
import { resolve, parse } from 'path';
|
2021-05-10 23:13:17 -04:00
|
|
|
import { readdirSync } from 'fs';
|
|
|
|
|
|
2021-05-06 23:05:36 -04:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
const { get, set } = _;
|
2021-05-02 17:42:04 -04:00
|
|
|
import Module from './Module.js';
|
|
|
|
|
import System from './System.js';
|
2021-05-10 23:13:17 -04:00
|
|
|
import * as log from './debug.js';
|
|
|
|
|
import createAst from './createAst.js';
|
2021-05-02 17:42:04 -04:00
|
|
|
|
2021-05-06 09:33:28 -04:00
|
|
|
// globals inside grammar context
|
|
|
|
|
import minify from './minify.js';
|
2021-05-02 17:42:04 -04:00
|
|
|
|
2021-05-06 09:33:28 -04:00
|
|
|
Object.defineProperty(Array.prototype, 'empty', {
|
|
|
|
|
get() {
|
|
|
|
|
return this.length === 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-02 17:42:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const systemLocation = resolve(process.argv[2]);
|
|
|
|
|
const entry = process.argv[3];
|
|
|
|
|
|
2021-05-06 23:05:36 -04:00
|
|
|
(async () => {
|
|
|
|
|
// TODO simplify this line gaddam
|
2021-05-08 23:06:31 -04:00
|
|
|
const modules =
|
|
|
|
|
(await Promise.all(
|
|
|
|
|
readdirSync(systemLocation)
|
|
|
|
|
.map(v => resolve(systemLocation, v))
|
2021-05-10 23:13:17 -04:00
|
|
|
.map(loc => new Module(loc))
|
2021-05-08 23:06:31 -04:00
|
|
|
)).reduce((acc, val) => {
|
|
|
|
|
set(acc, val.name.full, val);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
2021-05-06 23:05:36 -04:00
|
|
|
const sys = new System(modules);
|
|
|
|
|
})()
|