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

fix(core): do not use the new pty function for older versions of windows #21854

Merged
merged 3 commits into from Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 41 additions & 16 deletions packages/nx/src/tasks-runner/task-orchestrator.ts
Expand Up @@ -23,6 +23,7 @@ import {
getEnvVariablesForTask,
getTaskSpecificEnv,
} from './task-env';
import * as os from 'os';

export class TaskOrchestrator {
private cache = new Cache(this.options);
Expand Down Expand Up @@ -401,23 +402,25 @@ export class TaskOrchestrator {
streamOutput: boolean
) {
try {
let usePtyFork =
process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
supportedPtyPlatform();
// execution
const { code, terminalOutput } =
process.env.NX_NATIVE_COMMAND_RUNNER !== 'false'
? await this.forkedProcessTaskRunner.forkProcess(task, {
temporaryOutputPath,
streamOutput,
pipeOutput,
taskGraph: this.taskGraph,
env,
})
: await this.forkedProcessTaskRunner.forkProcessLegacy(task, {
temporaryOutputPath,
streamOutput,
pipeOutput,
taskGraph: this.taskGraph,
env,
});
const { code, terminalOutput } = usePtyFork
? await this.forkedProcessTaskRunner.forkProcess(task, {
temporaryOutputPath,
streamOutput,
pipeOutput,
taskGraph: this.taskGraph,
env,
})
: await this.forkedProcessTaskRunner.forkProcessLegacy(task, {
temporaryOutputPath,
streamOutput,
pipeOutput,
taskGraph: this.taskGraph,
env,
});

return {
code,
Expand Down Expand Up @@ -617,3 +620,25 @@ export class TaskOrchestrator {

// endregion utils
}

function supportedPtyPlatform() {
if (process.platform !== 'win32') {
return true;
}

let windowsVersion = os.release().split('.');
let windowsBuild = windowsVersion[2];

if (!windowsBuild) {
return false;
}

// Mininum supported Windows version:
// https://en.wikipedia.org/wiki/Windows_10,_version_1809
// https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
if (+windowsBuild < 17763) {
return false;
} else {
return true;
}
}