Skip to content

HCK-7253: fix getting target script for documentation #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };