-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrunn.js
36 lines (30 loc) · 793 Bytes
/
brunn.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
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
const blessed = require('blessed');
const process = require('process');
const shell = require('shelljs');
const packageJson = require(`${process.cwd()}/package.json`);
const screen = blessed.screen({ smartCSR: true });
screen.title = 'ncrun';
const list = blessed.list({
parent: screen,
keys: true,
vi: true,
style: {
selected: {
fg: '#2e2e2e',
bg: '#cecece',
}
},
items: Object.keys(packageJson.scripts),
});
list.on('select', item => {
screen.destroy();
shell.echo(`Running --- ${item.getText()} ---`);
if (shell.exec(`npm run ${item.getText()} --color always`).code !== 0) {
shell.exit(1);
}
});
// Quit on Escape, q, or Control-C.
screen.key(['escape', 'q', 'C-c'], () => shell.exit(1));
list.focus();
screen.render();