-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodeToolV0: allow reading versionSpec from file #15615
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
56e9a71
NodeToolV0: allow reading versionSpec from file
1670fef
fix version number
e8a1df5
fix version number some more
31ebc5c
Merge branch 'master' into nodetool-nvmrc
fowl2 6b49049
Merge branch 'master' into nodetool-nvmrc
fowl2 de80cd3
Merge branch 'master' into nodetool-nvmrc
fowl2 a821f0f
Merge branch 'master' into nodetool-nvmrc
EzzhevNikita b2a0789
Merge branch 'master' into nodetool-nvmrc
fowl2 9b1210f
Merge branch 'master' into nodetool-nvmrc
fowl2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import ma = require('azure-pipelines-task-lib/mock-answer'); | ||
import tmrm = require('azure-pipelines-task-lib/mock-run'); | ||
import os = require('os'); | ||
import path = require('path'); | ||
import semver = require('semver'); | ||
|
||
let taskPath = path.join(__dirname, '..', 'nodetool.js'); | ||
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); | ||
|
||
tmr.setInput('versionSpec', 'src/.nvmrc'); | ||
|
||
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{ | ||
"assertAgent": { | ||
"2.115.1": true | ||
}, | ||
"checkPath": { | ||
".nvmrc": true, | ||
}, | ||
}; | ||
tmr.setAnswers(a); | ||
|
||
|
||
//Create assertAgent and getVariable mocks | ||
const tl = require('azure-pipelines-task-lib/mock-task'); | ||
const tlClone = Object.assign({}, tl); | ||
tlClone.getVariable = function (variable: string) { | ||
if (variable.toLowerCase() == 'agent.tempdirectory') { | ||
return 'temp'; | ||
} | ||
return null; | ||
}; | ||
tlClone.assertAgent = function (variable: string) { | ||
return; | ||
}; | ||
tmr.registerMock('azure-pipelines-task-lib/mock-task', tlClone); | ||
|
||
tmr.registerMock('fs', { | ||
readFileSync: function (path, options) { | ||
if (path != 'src/.nvmrc') { | ||
throw new Error(`reading wrong .nvmrc: '${[path]}'`); | ||
} | ||
|
||
return '0.6.21'; | ||
} | ||
}); | ||
|
||
//Create tool-lib mock | ||
tmr.registerMock('azure-pipelines-tool-lib/tool', { | ||
isExplicitVersion: semver.valid, | ||
findLocalTool: function (toolName, versionSpec) { | ||
if (toolName != 'node') { | ||
throw new Error('Searching for wrong tool'); | ||
} | ||
return false; | ||
}, | ||
evaluateVersions: function (versions, versionSpec) { | ||
if (versionSpec !== 'v0.6.21') { | ||
throw new Error(`Incorrect versionSpec: ${versionSpec}`); | ||
} | ||
return versionSpec; | ||
}, | ||
cleanVersion: semver.clean, | ||
downloadTool(url) { | ||
let err = new Error(); | ||
err['httpStatusCode'] = '404'; | ||
if (url === `https://nodejs.org/dist/v0.6.21/node-v0.6.21-win-${os.arch()}.7z` || | ||
url === `https://nodejs.org/dist/v0.6.21/node-v0.6.21-${os.platform()}-${os.arch()}.tar.gz`) { | ||
throw err; | ||
} | ||
else if (url === `https://nodejs.org/dist/v0.6.21/win-${os.arch()}/node.exe`) { | ||
throw err; | ||
} | ||
else if (url === `https://nodejs.org/dist/v0.6.21/win-${os.arch()}/node.lib`) { | ||
throw err; | ||
} | ||
else if (url === `https://nodejs.org/dist/v0.6.21/node.exe`) { | ||
return 'exe_loc'; | ||
} | ||
else if (url === `https://nodejs.org/dist/v0.6.21/node.lib`) { | ||
return 'exe_lib'; | ||
} | ||
else { | ||
throw new Error(`Incorrect URL: ${url}`); | ||
} | ||
}, | ||
extract7z(downloadPath, extPath, _7zPath) { | ||
return 'extPath'; | ||
}, | ||
extractTar(downloadPath, extPath, _7zPath) { | ||
return 'extPath'; | ||
}, | ||
cacheDir(dir, tool, version) { | ||
return 'path to tool'; | ||
}, | ||
prependPath(toolPath) { | ||
return; | ||
} | ||
}); | ||
|
||
tmr.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it make sense to add separate task input for version spec specified as file path - to avoid any confusion around it?