Skip to content

Commit

Permalink
fix: npm commands for building dependency tree not working in windows…
Browse files Browse the repository at this point in the history
… os"

Signed-off-by: Zvi Grinberg <[email protected]>
  • Loading branch information
zvigrinberg committed Jul 10, 2024
1 parent ab74fc3 commit d900760
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/providers/javascript_npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ export var npmInteractions = {
})
},
createPackageLock: function createPackageLock(npm, manifestDir) {
// in windows os, --prefix flag doesn't work, it behaves really weird , instead of installing the package.json fromm the prefix folder,
// it's installing package.json (placed in current working directory of process) into prefix directory, so
let originalDir = process.cwd()

Check failure on line 28 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 28 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
if(os.platform() === 'win32') {

Check failure on line 29 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 29 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
process.chdir(manifestDir)

Check failure on line 30 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 30 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
}

Check failure on line 31 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 31 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
execSync(`${handleSpacesInPath(npm)} i --package-lock-only --prefix ${handleSpacesInPath(manifestDir)}`, err => {
if (err) {
throw new Error('failed to create npmOutput list')
}
})
if(os.platform() === 'win32') {

Check failure on line 37 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 37 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
process.chdir(originalDir)

Check failure on line 38 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 38 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
}

Check failure on line 39 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Mixed spaces and tabs

Check failure on line 39 in src/providers/javascript_npm.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Mixed spaces and tabs
}
}
export default { isSupported, provideComponent, provideStack, npmInteractions }
Expand Down Expand Up @@ -109,7 +118,7 @@ function provideComponent(data, opts = {}, path = '') {
* @return {string} returns a string containing the result output.
*/
function getNpmListing(npm, allFilter, manifestDir) {
return `${handleSpacesInPath(npm)} ls${allFilter} --omit=dev --package-lock-only --json --prefix ${handleSpacesInPath(manifestDir)}`;
return `${handleSpacesInPath(npm)} ls${allFilter} --omit=dev --package-lock-only --json --prefix ${manifestDir}`;
}


Expand Down

0 comments on commit d900760

Please sign in to comment.