Skip to content

Commit

Permalink
feat(core): handling sub directory with feature generation (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
csimpi authored and NathanWalker committed Aug 11, 2021
1 parent b433835 commit 959d3d8
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/xplat/src/utils/xplat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ export namespace XplatFeatureHelpers {
* Skip formatting
*/
skipFormat?: boolean;
/**
* The directory of the new feature
*/
directory?: string;
/**
* testing helper
*/
Expand Down Expand Up @@ -1128,12 +1132,22 @@ export namespace XplatFeatureHelpers {
extra: string = '',
framework?: FrameworkTypes
) {
//Handle "/" in name
options.directory = options.directory || '';
const folderParts = options.name.split('/');
if (folderParts.length > 1) {
options.name = folderParts[folderParts.length - 1];
folderParts.pop();
options.directory = folderParts.join('/') + '/';
}
let moveTo: string;
if (target) {
moveTo = getMoveTo(options, target, projectName, framework);
} else {
target = 'lib';
moveTo = `libs/xplat/features/src/lib/${options.name.toLowerCase()}`;
moveTo = `libs/xplat/features/src/lib/${
options.directory
}${options.name.toLowerCase()}`;
}
if (!extra) {
// make sure no `null` or `undefined` values get in the string path
Expand Down Expand Up @@ -1193,6 +1207,7 @@ export namespace XplatFeatureHelpers {
<PlatformTypes>platform,
framework
);

return {
...(options as any),
...getDefaultTemplateOptions(),
Expand All @@ -1215,12 +1230,12 @@ export namespace XplatFeatureHelpers {
);
// console.log('getMoveTo xplatFolderName:', xplatFolderName);
const featureName = options.name.toLowerCase();
let moveTo = `libs/xplat/${xplatFolderName}/features/src/lib/${featureName}`;
let moveTo = `libs/xplat/${xplatFolderName}/features/src/lib/${options.directory}${featureName}`;
if (projectName) {
let appDir = ['web', 'web-angular'].includes(xplatFolderName)
? '/app'
: '';
moveTo = `apps/${projectName}/src${appDir}/features/${featureName}`;
moveTo = `apps/${projectName}/src${appDir}/features/${options.directory}${featureName}`;
// console.log('moveTo:', moveTo);
}
return moveTo;
Expand Down

0 comments on commit 959d3d8

Please sign in to comment.