File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
- import { exec } from 'child_process' ;
2
- import { Readable } from 'stream' ;
1
+ import { execSync } from 'child_process' ;
3
2
4
3
/**
5
4
* Get the current npm version
6
5
* @return {String } The npm version
7
6
*/
8
7
export function getNpmVersion ( ) : string {
9
- const version = exec ( 'npm --version' ) ;
10
- return ( version . stdout as Readable ) . toString ( ) ;
8
+ const version = execSync ( 'npm --version' ) ;
9
+ return version . toString ( ) ;
11
10
}
Original file line number Diff line number Diff line change 1
1
import sinon from 'sinon' ;
2
2
import { expect } from 'chai' ;
3
+ import * as semver from 'semver' ;
3
4
import { CommandOptions } from '../../src/types' ;
4
5
import handleInput from '../../src/handlers/handleInput' ;
6
+ import { getNpmVersion } from '../../src/utils/npm' ;
5
7
6
8
describe ( 'Flags' , ( ) => {
7
9
describe ( 'default' , ( ) => {
@@ -92,7 +94,9 @@ describe('Flags', () => {
92
94
it ( 'should be able to set production mode from the command flag correctly' , ( ) => {
93
95
const callbackStub = sinon . stub ( ) ;
94
96
const options = { production : true } ;
95
- const auditCommand = 'npm audit --omit=dev' ;
97
+ const npmVersion = getNpmVersion ( ) ;
98
+ const flag = semver . satisfies ( npmVersion , '<=8.13.2' ) ? '--production' : '--omit=dev' ;
99
+ const auditCommand = `npm audit ${ flag } ` ;
96
100
const auditLevel = 'info' ;
97
101
const exceptionIds : string [ ] = [ ] ;
98
102
You can’t perform that action at this time.
0 commit comments