-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcli.js
executable file
·26 lines (19 loc) · 912 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
import tinyjam from './index.js';
import {readFileSync} from 'fs';
import {performance} from 'perf_hooks';
const version = JSON.parse(readFileSync(new URL('./package.json', import.meta.url))).version;
if (process.argv.length < 3) {
console.log(`tinyjam v${version}`);
console.log('usage: tinyjam source_dir [output_dir] [--breaks] [--smartypants] [--silent]');
} else {
const [src, out] = process.argv.slice(2).filter(s => !s.startsWith('--'));
const breaks = process.argv.includes('--breaks');
const smartypants = process.argv.includes('--smartypants');
const log = !process.argv.includes('--silent');
if (log) console.log(`tinyjam v${version}\n`);
const start = performance.now();
tinyjam(src, out, {log, breaks, smartypants});
const elapsed = performance.now() - start;
if (log) console.log(`\nDone in ${elapsed.toLocaleString()}ms.`);
}