Fix Commit - Committing fix whereby NPM Audit Actions Fails when running on Windows OS (#122)

- This commit is to fix an issue when running the 'npm-audit-action' on the 'windows-latest'
- Integrated the 'spawnSync' to use the right 'npm' script based upon the OS used
This commit is contained in:
Shaid Khan
2022-05-11 23:45:03 +01:00
committed by GitHub
parent c0410c237f
commit 33a41db91d
4 changed files with 1319 additions and 1302 deletions

View File

@@ -15,6 +15,9 @@ export class Audit {
try {
const auditOptions: Array<string> = ['audit', '--audit-level', auditLevel]
const isWindowsEnvironment: boolean = process.platform == "win32";
const cmd: string = (isWindowsEnvironment) ? 'npm.cmd' : 'npm';
if (productionFlag === 'true') {
auditOptions.push('--production')
}
@@ -23,7 +26,7 @@ export class Audit {
auditOptions.push('--json')
}
const result: SpawnSyncReturns<string> = spawnSync('npm', auditOptions, {
const result: SpawnSyncReturns<string> = spawnSync(cmd, auditOptions, {
encoding: 'utf-8',
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
})