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:
5
.github/workflows/daily.yml
vendored
5
.github/workflows/daily.yml
vendored
@@ -7,7 +7,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
scan:
|
scan:
|
||||||
name: npm audit
|
name: npm audit
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|||||||
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@@ -8,7 +8,10 @@ on: # rebuild any PRs and main branch changes
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build: # make sure build/ci work properly
|
build: # make sure build/ci work properly
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: |
|
- run: |
|
||||||
@@ -17,8 +20,12 @@ jobs:
|
|||||||
- uses: coverallsapp/github-action@master
|
- uses: coverallsapp/github-action@master
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
test: # make sure the action works on a clean machine without building
|
test: # make sure the action works on a clean machine without building
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
env:
|
env:
|
||||||
|
|||||||
2600
dist/index.js
vendored
2600
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,9 @@ export class Audit {
|
|||||||
try {
|
try {
|
||||||
const auditOptions: Array<string> = ['audit', '--audit-level', auditLevel]
|
const auditOptions: Array<string> = ['audit', '--audit-level', auditLevel]
|
||||||
|
|
||||||
|
const isWindowsEnvironment: boolean = process.platform == "win32";
|
||||||
|
const cmd: string = (isWindowsEnvironment) ? 'npm.cmd' : 'npm';
|
||||||
|
|
||||||
if (productionFlag === 'true') {
|
if (productionFlag === 'true') {
|
||||||
auditOptions.push('--production')
|
auditOptions.push('--production')
|
||||||
}
|
}
|
||||||
@@ -23,7 +26,7 @@ export class Audit {
|
|||||||
auditOptions.push('--json')
|
auditOptions.push('--json')
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: SpawnSyncReturns<string> = spawnSync('npm', auditOptions, {
|
const result: SpawnSyncReturns<string> = spawnSync(cmd, auditOptions, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
|
maxBuffer: SPAWN_PROCESS_BUFFER_SIZE
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user