madrun 9.0.7 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +10 -0
- package/bin/madrun.mjs +17 -13
- package/lib/choose.mjs +36 -0
- package/package.json +3 -2
package/ChangeLog
CHANGED
package/bin/madrun.mjs
CHANGED
|
@@ -12,6 +12,8 @@ import yargsParser from 'yargs-parser';
|
|
|
12
12
|
|
|
13
13
|
import {series} from '../lib/madrun.js';
|
|
14
14
|
import check from '../lib/check.js';
|
|
15
|
+
import {choose} from '../lib/choose.mjs';
|
|
16
|
+
|
|
15
17
|
const require = createRequire(import.meta.url);
|
|
16
18
|
|
|
17
19
|
const {exit} = process;
|
|
@@ -48,13 +50,13 @@ const {
|
|
|
48
50
|
if (help) {
|
|
49
51
|
const {help} = require('../lib/help.js');
|
|
50
52
|
console.log(help());
|
|
51
|
-
|
|
53
|
+
exit();
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
if (version) {
|
|
55
57
|
const {version} = require('../package.json');
|
|
56
58
|
console.log(`v${version}`);
|
|
57
|
-
|
|
59
|
+
exit();
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
if (init) {
|
|
@@ -77,42 +79,44 @@ if (init) {
|
|
|
77
79
|
console.error(error);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
let names = args._;
|
|
81
83
|
const options = getOptions(args['--']);
|
|
82
|
-
const [dir,
|
|
84
|
+
const [dir, scripts] = await getScript();
|
|
83
85
|
|
|
84
|
-
const problems = check(
|
|
86
|
+
const problems = check(scripts);
|
|
85
87
|
|
|
86
88
|
if (problems) {
|
|
87
89
|
const result = await putoutMadrun(dir, {fix});
|
|
88
90
|
|
|
89
91
|
if (fix) {
|
|
90
|
-
|
|
92
|
+
exit();
|
|
91
93
|
} else {
|
|
92
94
|
console.log(result);
|
|
93
|
-
|
|
95
|
+
exit(1);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
if (init)
|
|
98
|
-
|
|
100
|
+
exit();
|
|
99
101
|
|
|
100
102
|
if (problems) {
|
|
101
103
|
await execute(`echo '${problems}'`);
|
|
102
|
-
|
|
104
|
+
exit(1);
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
if (!names.length) {
|
|
106
|
-
|
|
107
|
-
exit();
|
|
108
|
+
names = await choose(scripts);
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
if (!names.length)
|
|
112
|
+
exit();
|
|
113
|
+
|
|
110
114
|
const env = {};
|
|
111
|
-
const [e, cmd] = await tryToCatch(series, names, options, env,
|
|
115
|
+
const [e, cmd] = await tryToCatch(series, names, options, env, scripts);
|
|
112
116
|
|
|
113
117
|
if (e) {
|
|
114
118
|
console.error(e.message);
|
|
115
|
-
|
|
119
|
+
exit(1);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
console.log(getOutput({cmd, cwd}));
|
package/lib/choose.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import enquirer from 'enquirer';
|
|
2
|
+
import actions from 'enquirer/lib/combos.js';
|
|
3
|
+
import tryToCatch from 'try-to-catch';
|
|
4
|
+
|
|
5
|
+
const {MultiSelect} = enquirer;
|
|
6
|
+
|
|
7
|
+
const custom = {
|
|
8
|
+
h: 'left',
|
|
9
|
+
j: 'down',
|
|
10
|
+
k: 'up',
|
|
11
|
+
l: 'right',
|
|
12
|
+
enter: 'i',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
actions.keys = {
|
|
16
|
+
...actions.keys,
|
|
17
|
+
...custom,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const choose = async (scripts) => {
|
|
21
|
+
const prompt = new MultiSelect({
|
|
22
|
+
message: 'Run:',
|
|
23
|
+
onSubmit() {
|
|
24
|
+
this.enable(this.focused);
|
|
25
|
+
},
|
|
26
|
+
choices: Object.keys(scripts),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const answer = await run(prompt);
|
|
30
|
+
return answer || [];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
async function run(prompt) {
|
|
34
|
+
const [, answer] = await tryToCatch(prompt.run.bind(prompt));
|
|
35
|
+
return answer;
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "madrun",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "CLI tool to run multiple npm-scripts in a madly comfortable way",
|
|
5
5
|
"main": "lib/madrun.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -58,12 +58,13 @@
|
|
|
58
58
|
"@putout/formatter-dump": "^4.0.0",
|
|
59
59
|
"@putout/plugin-madrun": "^14.0.0",
|
|
60
60
|
"all-object-keys": "^2.0.0",
|
|
61
|
+
"enquirer": "^2.3.6",
|
|
61
62
|
"find-up": "^5.0.0",
|
|
62
63
|
"jessy": "^3.0.0",
|
|
63
64
|
"mapsome": "^1.0.0",
|
|
64
65
|
"montag": "^1.0.0",
|
|
65
66
|
"once": "^1.4.0",
|
|
66
|
-
"putout": "^
|
|
67
|
+
"putout": "^29.0.0",
|
|
67
68
|
"try-catch": "^3.0.0",
|
|
68
69
|
"try-to-catch": "^3.0.0",
|
|
69
70
|
"yargs-parser": "^21.0.0"
|