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-17 21:18:21 -04:00
|
|
|
import { parse, resolve, dirname } from 'path';
|
2021-05-16 20:41:45 -04:00
|
|
|
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-17 21:18:21 -04:00
|
|
|
import { fileURLToPath } from 'url';
|
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-17 21:18:21 -04:00
|
|
|
const standardLibrary = resolve(fileURLToPath(dirname(import.meta.url)), 'lib');
|
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, '...');
|
2021-05-17 21:18:21 -04:00
|
|
|
const files = [
|
|
|
|
|
...readdirSync(systemLocation).map(v => resolve(systemLocation, v)),
|
|
|
|
|
...readdirSync(standardLibrary).map(v => resolve(standardLibrary, v))
|
|
|
|
|
];
|
2021-05-16 20:41:45 -04:00
|
|
|
const fullpaths = files
|
|
|
|
|
.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-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
|
|
|
})()
|