This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
vogue/run.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

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';
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
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
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');
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)));
// 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-16 20:41:45 -04:00
const sys = new System(modules, systemLocation);
2021-05-06 23:05:36 -04:00
})()