Skip to content

Commit 66099ac

Browse files
authored
chore(export-to-language): replace usage of vm module COMPASS-7312 (#4967)
1 parent 2d07d1d commit 66099ac

File tree

4 files changed

+12
-45
lines changed

4 files changed

+12
-45
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-export-to-language/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"chai": "^4.3.6",
8181
"compass-preferences-model": "^2.15.1",
8282
"depcheck": "^1.4.1",
83+
"ejson-shell-parser": "^1.2.4",
8384
"enzyme": "^3.11.0",
8485
"eslint": "^7.25.0",
8586
"hadron-app-registry": "^9.0.11",

packages/compass-export-to-language/src/modules/count-aggregation-stages-in-string.js

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import parseShellBSON, { ParseMode } from 'ejson-shell-parser';
2+
3+
export function countAggregationStagesInString(source: string): number {
4+
const parsed = parseShellBSON(source, { mode: ParseMode.Loose });
5+
if (!Array.isArray(parsed)) {
6+
throw new Error('Source expression is not an aggregation stage array');
7+
}
8+
return parsed.length;
9+
}

0 commit comments

Comments
 (0)