Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"loc.instanceNameFormat": "Use Node $(versionSpec)",
"loc.input.label.version": "Version",
"loc.input.help.version": "Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0",
"loc.input.label.versionFilePath": "Version File Path",
"loc.input.help.versionFilePath": "File path to get version. Example: src/.nvmrc",
"loc.input.label.checkLatest": "Check for Latest Version",
"loc.input.help.checkLatest": "Always checks online for the latest available version that satisfies the version spec. This is typically false unless you have a specific scenario to always get latest. This will cause it to incur download costs when potentially not necessary, especially with the hosted build pool.",
"loc.input.label.force32bit": "Use 32 bit version on x64 agents",
Expand Down
7 changes: 7 additions & 0 deletions Tasks/UseNodeV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
"required": false,
"helpMarkDown": "Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0"
},
{
"name": "versionFilePath",
"type": "string",
"label": "Version File Path",
"required": false,
"helpMarkDown": "File path to get version. Example: src/.nvmrc"
},
{
"name": "checkLatest",
"type": "boolean",
Expand Down
7 changes: 7 additions & 0 deletions Tasks/UseNodeV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.version"
},
{
"name": "versionFilePath",
"type": "string",
"label": "ms-resource:loc.input.label.versionFilePath",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.versionFilePath"
},
{
"name": "checkLatest",
"type": "boolean",
Expand Down
11 changes: 10 additions & 1 deletion Tasks/UseNodeV1/usenode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as taskLib from 'azure-pipelines-task-lib/task';
import * as installer from './installer';
import * as proxyutil from './proxyutil';
import * as path from 'path';
import * as fs from 'fs';

async function run() {
try {
Expand All @@ -20,7 +21,7 @@ async function run() {
// If not supplied then task is still used to setup proxy, auth, etc...
//
taskLib.setResourcePath(path.join(__dirname, 'task.json'));
const version = taskLib.getInput('version', false);
const version = getNodeVersion(taskLib.getInput('version', false), taskLib.getInput('versionFilePath', false));
const nodejsMirror = taskLib.getInput('nodejsMirror', false) || 'https://nodejs.org/dist/';
const retryCountOnDownloadFails = taskLib.getInput('retryCountOnDownloadFails', false) || "5";
const delayBetweenRetries = taskLib.getInput('delayBetweenRetries', false) || "1000";
Expand All @@ -39,4 +40,12 @@ async function run() {
}
}

function getNodeVersion(versionSpecInput: string, versionFilePathInput: string) {
if (versionFilePathInput) {
return fs.readFileSync(versionFilePathInput, { 'encoding': 'utf8' });
}

return versionSpecInput;
}

run()