Skip to content
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

Added node16 to task.schema.json #852

Merged
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
25 changes: 11 additions & 14 deletions node/mock-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "id",
"name": "Node14Task",
"name": "Node16Task",
"execution": {
"Node14": {
"Node16": {
"target": "usedotnet.js"
}
}
Expand Down
6 changes: 3 additions & 3 deletions node/test/mocktests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
});
9 changes: 9 additions & 0 deletions tasks.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -404,6 +407,9 @@
"additionalProperties": false,
"description": "Execution options for this task",
"properties": {
"Node16": {
"$ref": "#/definitions/executionObject"
},
"Node10": {
"$ref": "#/definitions/executionObject"
},
Expand All @@ -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"
},
Expand Down