Skip to content

Commit 48be574

Browse files
fix setLayout
1 parent bbc0006 commit 48be574

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

packages/devextreme-cli/testing/env.angular.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const sandboxPath = path.join(process.cwd(), './testing/sandbox/angular');
1111
const appPath = path.join(sandboxPath, appName);
1212
const schematicsDirectory = '../../../../devextreme-schematics';
1313
const schematicsPath = path.join(sandboxPath, schematicsDirectory);
14-
const appComponentPath = path.join(appPath, 'src/app/app.component.html');
14+
const appComponentTemplatePath = path.join(appPath, 'src/app/app.component.html');
15+
const appComponentPath = path.join(appPath, 'src/app/app.component.ts');
1516

1617
async function prepareSchematics() {
1718
await packageManager.runInstall({
@@ -62,9 +63,25 @@ exports.createApp = async(depsVersionTag) => {
6263
};
6364

6465
exports.setLayout = (layoutName) => {
65-
const regexToFind = /app-side-nav-\w+-toolbar/g;
66-
const newSubStr = `app-${layoutName}`;
67-
const data = fs.readFileSync(appComponentPath, 'utf8');
68-
const result = data.replace(regexToFind, newSubStr);
69-
fs.writeFileSync(appComponentPath, result, 'utf8');
66+
const layoutClassName = layoutName === 'side-nav-outer-toolbar'
67+
? 'SideNavOuterToolbarComponent'
68+
: 'SideNavInnerToolbarComponent';
69+
70+
[
71+
{
72+
filePath: appComponentTemplatePath,
73+
regexp: /app-side-nav-\w+-toolbar/g,
74+
replacement: `app-${layoutName}`,
75+
},
76+
{
77+
filePath: appComponentPath,
78+
regexp: /SideNav\w+ToolbarComponent/,
79+
replacement: layoutClassName,
80+
}
81+
].forEach(({ filePath, regexp, replacement }) => {
82+
const data = fs.readFileSync(filePath, 'utf8');
83+
const result = data.replace(regexp, replacement);
84+
fs.writeFileSync(filePath, result, 'utf8');
85+
});
86+
7087
};

0 commit comments

Comments
 (0)