-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
25 lines (21 loc) · 799 Bytes
/
index.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
#!/usr/bin/env node
const { hideBin } = require('yargs/helpers')
const yargs = require('yargs/yargs');
const path = require('path');
const { writeToDisk } = require('./lib/writeToDisk');
/** @typedef {import('./lib/profile').Profiles} Profiles */
yargs(hideBin(process.argv))
.command(['run <generator>', '$0'], 'run a generator script', {}, argv => {
try {
const generatorPath = path.resolve(/** @type {string} */(argv.generator));
console.log(`Loading ${generatorPath}`);
const relativePath = path.relative(__dirname, generatorPath);
/** @type {function(Object): Profiles} */
const fn = require('.' + path.sep + relativePath);
const profiles = fn(argv);
writeToDisk(profiles);
} catch(err) {
console.error(err);
}
})
.parse();