Skip to content

Commit

Permalink
Merge pull request #270 from nodists/fix_npm_install
Browse files Browse the repository at this point in the history
fix(npm): fetching npm versions not working
  • Loading branch information
Mairu authored Dec 9, 2023
2 parents 97e698c + c3c0eec commit 941d2ca
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ jobs:
- name: Copy Node.exe to repository directory
run: Copy-Item (Get-Command node.exe | Select-Object -ExpandProperty Definition) .
- run: npm test
env:
NODIST_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ MIT License

## Changelog

v0.10.3
* Fix installing of npm versions

v0.10.2
* Fix building shims (for newer go versions) by using go modules
* Fix npm shim to use correct node version
Expand Down
9 changes: 5 additions & 4 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module.exports = npmist

var NPMIST = npmist.prototype

const versionRegex = /^v\d+\.\d+\.\d+$/;

/**
* List available NPM versions
* @return {string}
Expand All @@ -60,10 +62,9 @@ NPMIST.listAvailable = function(){
.then(([npm, cli]) => {
// The npm project has two kinds of releases: releases of npm,
// and releases of other utility libraries.
// Ignore the releases of libraries. They are named "package: version",
// Ignore the releases of libraries. They are named "library-version",
// while core npm releases are named just "version".
cli = cli.filter( release => release.name.indexOf(':') < 0 );

cli = cli.filter(release => versionRegex.test(release));
return npm.concat(cli);
});
};
Expand Down Expand Up @@ -111,7 +112,7 @@ function getNpmReleases(page) {
per_page: 50,
page,
}).then((response) => response.data.map(release => release.tag_name)
.filter((version) => /^v\d+\.\d+\.\d+$/.test(version))
.filter((version) => versionRegex.test(version))
.sort(semver.compare)
);
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodist",
"version": "0.10.2",
"version": "0.10.3",
"description": "Natural node version manager for windows",
"keywords": [
"node",
Expand Down
12 changes: 11 additions & 1 deletion test/npm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Npmist = require('../lib/npm');
const { createNodistInstance, promiseWithCallback } = require('./helper');

const npmBaseVersion = '6.10.1';
const versionRegex = /^v\d+\.\d+\.\d+/;

vows.describe('npm')
.addBatch({
Expand All @@ -17,7 +18,16 @@ vows.describe('npm')
'should return valid version number': (error, result) => {
assert.ifError(error);
debug('latestVersion: ' + result);
assert.match(result, /^v\d+\.\d+\.\d+$/);
assert.match(result, versionRegex);
}
},
'calling `listAvailable()`': {
topic(npmist) { promiseWithCallback(npmist.listAvailable(), this.callback); },
'should return an array of available versions': (error, result) => {
assert.ifError(error);
debug('listVersions: ' + result);
assert.ok(Array.isArray(result));
result.forEach((version) => assert.match(version, versionRegex));
}
}
}
Expand Down

0 comments on commit 941d2ca

Please sign in to comment.