diff --git a/node/mock-test.ts b/node/mock-test.ts index 37d379a3b..4d973387e 100644 --- a/node/mock-test.ts +++ b/node/mock-test.ts @@ -143,20 +143,17 @@ export class MockTestRunner { let downloadVersion: string; switch (version) { - case 5: - downloadVersion = 'v5.10.1'; - break; case 6: downloadVersion = 'v6.17.1'; break; case 10: downloadVersion = 'v10.21.0'; break; - case 14: - downloadVersion = 'v14.11.0'; + case 16: + downloadVersion = 'v16.13.0'; break; default: - throw new Error('Invalid node version, must be 5, 6, 10, or 14 (received ' + version + ')'); + throw new Error('Invalid node version, must be 6, 10, or 16 (received ' + version + ')'); } // Install node in home directory if it isn't already there. @@ -170,12 +167,12 @@ export class MockTestRunner { } } - // Determines the correct version of node to use based on the contents of the task's task.json. Defaults to Node 14. + // Determines the correct version of node to use based on the contents of the task's task.json. Defaults to Node 16. private getNodeVersion(): number { const taskJsonPath: string = this.getTaskJsonPath(); if (!taskJsonPath) { - console.warn('Unable to find task.json, defaulting to use Node 14'); - return 10; + console.warn('Unable to find task.json, defaulting to use Node 16'); + return 16; } const taskJsonContents = fs.readFileSync(taskJsonPath, { encoding: 'utf-8' }); const taskJson: object = JSON.parse(taskJsonContents); @@ -188,9 +185,9 @@ export class MockTestRunner { ); const keys = Object.keys(execution); for (let i = 0; i < keys.length; i++) { - if (keys[i].toLowerCase() == 'node14') { - // Prefer node 14 and return immediately. - return 14; + if (keys[i].toLowerCase() == 'node16') { + // Prefer node 16 and return immediately. + return 16; } else if (keys[i].toLowerCase() == 'node10') { // Prefer node 10 and return immediately. return 10; @@ -200,8 +197,8 @@ export class MockTestRunner { } if (!nodeVersionFound) { - console.warn('Unable to determine execution type from task.json, defaulting to use Node 10'); - return 10; + console.warn('Unable to determine execution type from task.json, defaulting to use Node 16'); + return 16; } return 6; diff --git a/node/test/fakeTasks/node14task/task.json b/node/test/fakeTasks/node16task/task.json similarity index 66% rename from node/test/fakeTasks/node14task/task.json rename to node/test/fakeTasks/node16task/task.json index a4825b6ec..4342d1603 100644 --- a/node/test/fakeTasks/node14task/task.json +++ b/node/test/fakeTasks/node16task/task.json @@ -1,8 +1,8 @@ { "id": "id", - "name": "Node14Task", + "name": "Node16Task", "execution": { - "Node14": { + "Node16": { "target": "usedotnet.js" } } diff --git a/node/test/mocktests.ts b/node/test/mocktests.ts index 30b7b2c2f..6c8e44095 100644 --- a/node/test/mocktests.ts +++ b/node/test/mocktests.ts @@ -318,13 +318,13 @@ describe('Mock Tests', function () { done(); }) - it('MockTest handles node 14 tasks correctly', function (done) { + it('MockTest handles node 16 tasks correctly', function (done) { this.timeout(30000); - const runner = new mtm.MockTestRunner(path.join(__dirname, 'fakeTasks', 'node14task', 'entry.js')); + const runner = new mtm.MockTestRunner(path.join(__dirname, 'fakeTasks', 'node16task', 'entry.js')); const nodePath = runner.nodePath; assert(nodePath, 'node path should have been correctly set'); const version = ncp.execSync(nodePath + ' -v').toString().trim(); - assert(semver.satisfies(version, '14.x'), 'Downloaded node version should be Node 14 instead of ' + version); + assert(semver.satisfies(version, '16.x'), 'Downloaded node version should be Node 16 instead of ' + version); done(); }) }); diff --git a/tasks.schema.json b/tasks.schema.json index 414d4157b..08dcde4d4 100644 --- a/tasks.schema.json +++ b/tasks.schema.json @@ -385,6 +385,9 @@ "additionalProperties": false, "description": "Execution options for this task (on Pre-Job stage)", "properties": { + "Node16": { + "$ref": "#/definitions/executionObject" + }, "Node10": { "$ref": "#/definitions/executionObject" }, @@ -404,6 +407,9 @@ "additionalProperties": false, "description": "Execution options for this task", "properties": { + "Node16": { + "$ref": "#/definitions/executionObject" + }, "Node10": { "$ref": "#/definitions/executionObject" }, @@ -423,6 +429,9 @@ "additionalProperties": false, "description": "Execution options for this task (on Post-Job stage)", "properties": { + "Node16": { + "$ref": "#/definitions/executionObject" + }, "Node10": { "$ref": "#/definitions/executionObject" },