@@ -6,6 +6,8 @@ import * as path from 'path';
66
77import {
88 getPlatformInfo ,
9+ npmExecutable ,
10+ npxExecutable ,
911 getCodeQLExePath ,
1012 getJavaScriptExtractorRoot ,
1113 setupJavaScriptExtractorEnv ,
@@ -125,6 +127,40 @@ describe('environment', () => {
125127 } ) ;
126128 } ) ;
127129
130+ describe ( 'npmExecutable' , ( ) => {
131+ it ( 'should return npm.cmd on Windows' , ( ) => {
132+ ( os . platform as jest . Mock ) . mockReturnValue ( 'win32' ) ;
133+ expect ( npmExecutable ( ) ) . toBe ( 'npm.cmd' ) ;
134+ } ) ;
135+
136+ it ( 'should return npm on Linux' , ( ) => {
137+ ( os . platform as jest . Mock ) . mockReturnValue ( 'linux' ) ;
138+ expect ( npmExecutable ( ) ) . toBe ( 'npm' ) ;
139+ } ) ;
140+
141+ it ( 'should return npm on macOS' , ( ) => {
142+ ( os . platform as jest . Mock ) . mockReturnValue ( 'darwin' ) ;
143+ expect ( npmExecutable ( ) ) . toBe ( 'npm' ) ;
144+ } ) ;
145+ } ) ;
146+
147+ describe ( 'npxExecutable' , ( ) => {
148+ it ( 'should return npx.cmd on Windows' , ( ) => {
149+ ( os . platform as jest . Mock ) . mockReturnValue ( 'win32' ) ;
150+ expect ( npxExecutable ( ) ) . toBe ( 'npx.cmd' ) ;
151+ } ) ;
152+
153+ it ( 'should return npx on Linux' , ( ) => {
154+ ( os . platform as jest . Mock ) . mockReturnValue ( 'linux' ) ;
155+ expect ( npxExecutable ( ) ) . toBe ( 'npx' ) ;
156+ } ) ;
157+
158+ it ( 'should return npx on macOS' , ( ) => {
159+ ( os . platform as jest . Mock ) . mockReturnValue ( 'darwin' ) ;
160+ expect ( npxExecutable ( ) ) . toBe ( 'npx' ) ;
161+ } ) ;
162+ } ) ;
163+
128164 describe ( 'getCodeQLExePath' , ( ) => {
129165 it ( 'should resolve codeql.exe path on Windows when CODEQL_DIST is set and valid' , ( ) => {
130166 // Setup platform
0 commit comments