Skip to content

Commit 5894af1

Browse files
committed
chore: create aliases for generators
c -> component d -> directive p -> pipe r -> route s -> service Closes #437
1 parent 9be9bd5 commit 5894af1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

addon/ng2/commands/generate.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const GenerateCommand = EmberGenerateCommand.extend({
1212
return;
1313
}
1414

15+
// map the blueprint name to allow for aliases
16+
rawArgs[0] = mapBlueprintName(rawArgs[0]);
17+
1518
if (!fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) {
1619
SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`);
1720
}
@@ -20,6 +23,18 @@ const GenerateCommand = EmberGenerateCommand.extend({
2023
}
2124
});
2225

26+
function mapBlueprintName(name) {
27+
let mappedName = aliasMap[name];
28+
return mappedName ? mappedName : name;
29+
}
30+
31+
const aliasMap = {
32+
'c': 'component',
33+
'd': 'directive',
34+
'p': 'pipe',
35+
'r': 'route',
36+
's': 'service'
37+
};
2338

2439
module.exports = GenerateCommand;
2540
module.exports.overrideCore = true;

0 commit comments

Comments
 (0)