Skip to content

Commit 2cd7911

Browse files
speedup: load inquirer only when needed
around 80ms improve on my machine $ avg_time 10 node ./bin/h1 --compbash --compgen _ _ "h1 " real 0.444000 user 0.443000 sys 0.070000 $ avg_time 10 node ./bin/h1 --compbash --compgen _ _ "h1 " real 0.367000 user 0.350000 sys 0.052000
1 parent 26c46f2 commit 2cd7911

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lib/interactive.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const inquirer = require('inquirer');
43
const Cli = require('./cli');
54

65
const verifyTTY= (fn) => (...args) => {
@@ -18,7 +17,7 @@ module.exports.prompt = verifyTTY((message, options = {}) => {
1817
validate: input => input.length === 0 ? 'Incorrect input' : true,
1918
}, options);
2019

21-
return inquirer.prompt(options);
20+
return require('inquirer').prompt(options);
2221
});
2322

2423
module.exports.select = verifyTTY((message, choices, options = {}) => {
@@ -30,7 +29,7 @@ module.exports.select = verifyTTY((message, choices, options = {}) => {
3029
validate: input => input.length === 0 ? 'Incorrect input' : true,
3130
}, options);
3231

33-
return inquirer.prompt(options);
32+
return require('inquirer').prompt(options);
3433
});
3534

3635
module.exports.confirm = verifyTTY((message, options = {}) => {
@@ -41,5 +40,5 @@ module.exports.confirm = verifyTTY((message, options = {}) => {
4140
default: false,
4241
}, options);
4342

44-
return inquirer.prompt(options);
43+
return require('inquirer').prompt(options);
4544
});

0 commit comments

Comments
 (0)