2021-05-02 17:42:04 -04:00
|
|
|
#!/usr/bin/env node
|
2021-05-16 20:41:45 -04:00
|
|
|
import debug from 'debug';
|
|
|
|
|
const log = debug('vogue:cli');
|
|
|
|
|
const systemLocation = resolve(process.argv[2]);
|
2021-05-02 17:42:04 -04:00
|
|
|
|
2021-05-16 20:41:45 -04:00
|
|
|
import { parse, resolve } from 'path';
|
|
|
|
|
import { readdirSync, lstatSync } from 'fs';
|
2021-05-10 23:13:17 -04:00
|
|
|
|
2021-05-06 23:05:36 -04:00
|
|
|
import _ from 'lodash';
|
2021-05-02 17:42:04 -04:00
|
|
|
import Module from './Module.js';
|
|
|
|
|
import System from './System.js';
|
2021-05-11 19:38:55 -04:00
|
|
|
import './extensions.js';
|
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-11 19:38:55 -04:00
|
|
|
const { get, set } = _;
|
2021-05-02 17:42:04 -04:00
|
|
|
|
2021-05-06 23:05:36 -04:00
|
|
|
(async () => {
|
|
|
|
|
// TODO simplify this line gaddam
|
2021-05-11 19:38:55 -04:00
|
|
|
log('reading', systemLocation, '...');
|
|
|
|
|
const files = readdirSync(systemLocation);
|
2021-05-16 20:41:45 -04:00
|
|
|
const fullpaths = files
|
|
|
|
|
.map(v => resolve(systemLocation, v))
|
|
|
|
|
.filter(v => lstatSync(v).isFile())
|
|
|
|
|
.filter(v => parse(v).ext === '.v');
|
2021-05-11 19:38:55 -04:00
|
|
|
for(const path of fullpaths) log(path);
|
|
|
|
|
log('parsing modules...');
|
2021-05-16 20:41:45 -04:00
|
|
|
const modules = await Promise.all(fullpaths.map(loc => Module.create(loc, systemLocation)));
|
2021-05-11 19:38:55 -04:00
|
|
|
|
|
|
|
|
// const modules =
|
|
|
|
|
// (await Promise.all(
|
|
|
|
|
// readdirSync(systemLocation)
|
|
|
|
|
// .map(v => resolve(systemLocation, v))
|
|
|
|
|
// .map(v => { log(v); return v; })
|
|
|
|
|
// .map(loc => Module.create(loc))
|
|
|
|
|
// )).reduce((acc, val) => {
|
|
|
|
|
// set(acc, val.name.full, val);
|
|
|
|
|
// return acc;
|
|
|
|
|
// }, {});
|
2021-05-08 23:06:31 -04:00
|
|
|
|
2021-05-16 20:41:45 -04:00
|
|
|
const sys = new System(modules, systemLocation);
|
2021-05-06 23:05:36 -04:00
|
|
|
})()
|