Skip to content

Commit 37bae12

Browse files
HCK-7253: fix getting target script for documentation (#41)
1 parent d625a20 commit 37bae12

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

forward_engineering/api.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ module.exports = {
1818
(data.entityData[entityId] || [])[0] || {},
1919
),
2020
);
21-
if (
22-
data.options.targetScriptOptions &&
23-
data.options.targetScriptOptions.keyword === 'containerSettingsJson'
24-
) {
21+
if (data.options?.targetScriptOptions?.keyword === 'containerSettingsJson') {
2522
const uniqueKeys = _.get(data.containerData, '[0].uniqueKey', []);
2623
const scriptData = {
2724
partitionKey: getPartitionKey(_)(data.containerData),
@@ -43,7 +40,6 @@ module.exports = {
4340

4441
const script = buildAzureCLIScript(_)({
4542
...data,
46-
shellName: data.options.targetScriptOptions.keyword.split('azureCli')[1].toLowerCase(),
4743
});
4844

4945
if (withSamples || !insertSamplesOption.value) {

forward_engineering/helpers/azureCLIScriptHelpers/buildAzureCLIScript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { getUniqueKeyPolicyScript } = require('../getUniqueKeyPolicyScript');
44
const { getCliParamsDelimiter } = require('./getCliParamsDelimiter');
55
const getIndexPolicyScript = require('../getIndexPolicyScript');
66
const getPartitionKey = require('../getPartitionKey');
7+
const { getCliShellName } = require('./getCliShellName');
78
const {
89
CLI,
910
DATABASE,
@@ -16,7 +17,8 @@ const {
1617

1718
const buildAzureCLIScript =
1819
_ =>
19-
({ modelData, containerData, shellName }) => {
20+
({ modelData, containerData, options }) => {
21+
const shellName = getCliShellName(options?.targetScriptOptions);
2022
const cliParamsDelimiter = getCliParamsDelimiter(shellName);
2123
const escapeAndWrapInQuotes = string => wrapInSingleQuotes(escapeShellCommand(shellName, string));
2224

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {object} targetScriptOptions
3+
* @returns {string}
4+
*/
5+
const getCliShellName = (targetScriptOptions = {}) => {
6+
const keyword = targetScriptOptions.keyword ?? '';
7+
const [, shellName = ''] = keyword.split('azureCli');
8+
9+
return shellName.toLowerCase();
10+
};
11+
12+
module.exports = { getCliShellName };

0 commit comments

Comments
 (0)