Skip to content

Commit 9502df5

Browse files
committed
Fix CDS extractor dist and shell exec
1 parent 3badc7b commit 9502df5

File tree

6 files changed

+39
-24
lines changed

6 files changed

+39
-24
lines changed

extractors/cds/tools/dist/cds-extractor.bundle.js

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

extractors/cds/tools/dist/cds-extractor.bundle.js.map

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

extractors/cds/tools/src/cds/compiler/version.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export function getCdsVersion(cdsCommand: string, cacheDir?: string): string | u
3030
}
3131

3232
// Execute the CDS command with the --version flag
33-
const result = spawnSync(cdsCommand, ['--version'], spawnOptions);
33+
// When shell: true is used, concatenate command and args to avoid DEP0190 deprecation warning
34+
const result = spawnSync(`${cdsCommand} --version`, spawnOptions);
3435
if (result.status === 0 && result.stdout) {
3536
const versionOutput = result.stdout.toString().trim();
3637
// Extract version number, which is typically in formats like "@sap/cds: 6.1.3" or similar

extractors/cds/tools/src/codeql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function runJavaScriptExtractor(
4141
* the current working directory set to the project (source) root directory
4242
* because it assumes it is running from there.
4343
*/
44-
const result: SpawnSyncReturns<Buffer> = spawnSync(autobuildScriptPath, [], {
44+
const result: SpawnSyncReturns<Buffer> = spawnSync(autobuildScriptPath, {
4545
cwd: sourceRoot,
4646
env: process.env,
4747
shell: true,

extractors/cds/tools/test/src/cds/compiler/version.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('version.ts', () => {
2727
const version = getCdsVersion('cds');
2828

2929
expect(version).toBe('6.1.3');
30-
expect(mockSpawnSync).toHaveBeenCalledWith('cds', ['--version'], {
30+
expect(mockSpawnSync).toHaveBeenCalledWith('cds --version', {
3131
shell: true,
3232
stdio: 'pipe',
3333
env: { ...process.env },
@@ -122,7 +122,7 @@ describe('version.ts', () => {
122122
const version = getCdsVersion('cds', cacheDir);
123123

124124
expect(version).toBe('6.1.3');
125-
expect(mockSpawnSync).toHaveBeenCalledWith('cds', ['--version'], {
125+
expect(mockSpawnSync).toHaveBeenCalledWith('cds --version', {
126126
shell: true,
127127
stdio: 'pipe',
128128
env: {
@@ -153,7 +153,7 @@ describe('version.ts', () => {
153153
const version = getCdsVersion('cds', cacheDir);
154154

155155
expect(version).toBe('6.1.3');
156-
expect(mockSpawnSync).toHaveBeenCalledWith('cds', ['--version'], {
156+
expect(mockSpawnSync).toHaveBeenCalledWith('cds --version', {
157157
shell: true,
158158
stdio: 'pipe',
159159
env: expect.objectContaining({
@@ -230,7 +230,7 @@ describe('version.ts', () => {
230230
const version = getCdsVersion('npx cds');
231231

232232
expect(version).toBe('6.1.3');
233-
expect(mockSpawnSync).toHaveBeenCalledWith('npx cds', ['--version'], expect.any(Object));
233+
expect(mockSpawnSync).toHaveBeenCalledWith('npx cds --version', expect.any(Object));
234234
});
235235

236236
it('should handle multiline version output', () => {

extractors/cds/tools/test/src/codeql.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as childProcess from 'child_process';
22

3+
import type { CdsDependencyGraph } from '../../src/cds/parser/types';
34
import {
45
handleEarlyExit,
56
runJavaScriptExtractor,
@@ -69,7 +70,6 @@ describe('codeql', () => {
6970
expect(result).toEqual({ success: true });
7071
expect(childProcess.spawnSync).toHaveBeenCalledWith(
7172
'/path/to/autobuild.sh',
72-
[],
7373
expect.objectContaining({
7474
cwd: '/path/to/source',
7575
env: process.env,
@@ -185,7 +185,7 @@ describe('codeql', () => {
185185
'/path/to/source',
186186
'/path/to/autobuild.sh',
187187
'/path/to/codeql',
188-
dependencyGraph as any,
188+
dependencyGraph as CdsDependencyGraph,
189189
);
190190

191191
expect(result).toBe(true);
@@ -268,7 +268,7 @@ describe('codeql', () => {
268268
'/path/to/source',
269269
'/path/to/autobuild.sh',
270270
'/path/to/codeql',
271-
dependencyGraph as any,
271+
dependencyGraph as CdsDependencyGraph,
272272
);
273273

274274
expect(addJavaScriptExtractorDiagnostic).toHaveBeenCalledWith(
@@ -287,7 +287,7 @@ describe('codeql', () => {
287287
beforeEach(() => {
288288
mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
289289
throw new Error('process.exit called');
290-
}) as any);
290+
}) as never);
291291
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
292292
(filesystem.createMarkerFile as jest.Mock).mockReturnValue('/path/to/marker.js');
293293
(filesystem.removeMarkerFile as jest.Mock).mockReturnValue(undefined);

0 commit comments

Comments
 (0)