Skip to content

Commit 8f41c2e

Browse files
committed
fix: Fix help text for cli
1 parent 7f71f42 commit 8f41c2e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/cli/lib/project-generator.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ module.exports = class extends Generator {
5353
});
5454
}
5555

56+
/**
57+
* Override the usage text by replacing `yo loopback4:` with `lb4 `.
58+
*/
59+
usage() {
60+
const text = super.usage();
61+
return text.replace(/^yo loopback4:/g, 'lb4 ');
62+
}
63+
5664
setOptions() {
5765
this.projectInfo = {};
5866
[

packages/cli/test/project.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@
77
const path = require('path');
88
const assert = require('yeoman-assert');
99
const helpers = require('yeoman-test');
10+
const yeoman = require('yeoman-environment');
1011

1112
module.exports = function(appGenerator, props) {
1213
return function() {
14+
describe('help', () => {
15+
it('prints lb4', () => {
16+
const env = yeoman.createEnv();
17+
const name = appGenerator.substring(appGenerator.lastIndexOf('/') + 1);
18+
env.register(appGenerator, 'loopback4:' + name);
19+
const generator = env.create('loopback4:' + name);
20+
const helpText = generator.help();
21+
assert(helpText.match(/lb4 /));
22+
assert(!helpText.match(/loopback4:/));
23+
});
24+
});
25+
1326
describe('without settings', () => {
1427
before(() => {
1528
return helpers.run(appGenerator).withPrompts(props);

0 commit comments

Comments
 (0)