Skip to content

Commit 066c286

Browse files
committed
fix apply to instance
1 parent 8c6c001 commit 066c286

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

forward_engineering/api.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ module.exports = {
8181
});
8282

8383
progress('Applying Cosmos DB script ...');
84-
const cosmosDBScript = JSON.parse(_.get(data, 'script[1].script', '""'));
84+
const splittedScript = data.script.split('\n');
85+
let cosmosDBStartLineNumber = splittedScript.indexOf('{');
86+
if (cosmosDBStartLineNumber === -1) {
87+
cosmosDBStartLineNumber = splittedScript.length;
88+
}
89+
let gremlinScript = splittedScript.slice(0, cosmosDBStartLineNumber).join('\n');
90+
let cosmosDBScript = JSON.parse(splittedScript.slice(cosmosDBStartLineNumber).join('\n') || '""');
8591

8692
progress('Update indexing policy ...');
8793

@@ -109,8 +115,6 @@ module.exports = {
109115
await applyToInstanceHelper.createTriggers(triggers, containerResponse.container);
110116
}
111117

112-
const gremlinScript = _.get(data, 'script[0].script', '');
113-
114118
if (!gremlinScript) {
115119
return cb();
116120
}

0 commit comments

Comments
 (0)