mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 15:02:22 +00:00
210680c9c9
In my system (MBPr 13), printing the current version takes over 2 seconds: ```sh $ time ./bin/resin version 2.4.0 ./bin/resin version 1.37s user 0.19s system 73% cpu 2.130 total ``` The CLI takes almost all of these time to parse the dependency tree before returning control over the actually called command. To mitigate this problem, we only require the NPM dependencies a command requires when executing such command, and thus prevent dependencies from being required and parsed unnecessary. After this improvement, printing the original example (`resin version`) returns in less than a second (2x improvement): ```sh $ time ./bin/resin version 2.4.0 ./bin/resin version 0.88s user 0.09s system 102% cpu 0.938 total ```
15 lines
470 B
JavaScript
15 lines
470 B
JavaScript
(function() {
|
|
exports.list = {
|
|
signature: 'settings',
|
|
description: 'print current settings',
|
|
help: 'Use this command to display detected settings\n\nExamples:\n\n $ resin settings',
|
|
action: function(params, options, done) {
|
|
var prettyjson, resin;
|
|
resin = require('resin-sdk');
|
|
prettyjson = require('prettyjson');
|
|
return resin.settings.getAll().then(prettyjson.render).then(console.log).nodeify(done);
|
|
}
|
|
};
|
|
|
|
}).call(this);
|