Skip to content

Commit

Permalink
HCK-7253: fix getting target script for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii-filonenko committed Jul 16, 2024
1 parent d625a20 commit 0863ade
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 1 addition & 5 deletions forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ module.exports = {
(data.entityData[entityId] || [])[0] || {},
),
);
if (
data.options.targetScriptOptions &&
data.options.targetScriptOptions.keyword === 'containerSettingsJson'
) {
if (data.options?.targetScriptOptions?.keyword === 'containerSettingsJson') {
const uniqueKeys = _.get(data.containerData, '[0].uniqueKey', []);
const scriptData = {
partitionKey: getPartitionKey(_)(data.containerData),
Expand All @@ -43,7 +40,6 @@ module.exports = {

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

if (withSamples || !insertSamplesOption.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { getUniqueKeyPolicyScript } = require('../getUniqueKeyPolicyScript');
const { getCliParamsDelimiter } = require('./getCliParamsDelimiter');
const getIndexPolicyScript = require('../getIndexPolicyScript');
const getPartitionKey = require('../getPartitionKey');
const { getCliShellName } = require('./getCliShellName');
const {
CLI,
DATABASE,
Expand All @@ -16,7 +17,8 @@ const {

const buildAzureCLIScript =
_ =>
({ modelData, containerData, shellName }) => {
({ modelData, containerData, options }) => {
const shellName = getCliShellName(options?.targetScriptOptions);
const cliParamsDelimiter = getCliParamsDelimiter(shellName);
const escapeAndWrapInQuotes = string => wrapInSingleQuotes(escapeShellCommand(shellName, string));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @param {object} targetScriptOptions
* @returns {string}
*/
const getCliShellName = (targetScriptOptions = {}) => {
const keyword = targetScriptOptions.keyword ?? '';
const [, shellName = ''] = keyword.split('azureCli');

return shellName.toLowerCase();
};

module.exports = { getCliShellName };

0 comments on commit 0863ade

Please sign in to comment.