Skip to content

Commit

Permalink
fix(core): do not use the new pty function for older versions of wind…
Browse files Browse the repository at this point in the history
…ows (#21854)
  • Loading branch information
Cammisuli authored and jaysoo committed Feb 23, 2024
1 parent da46c30 commit e974832
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions packages/nx/src/tasks-runner/task-orchestrator.ts
Original file line number Diff line number Diff line change
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;
}
}

0 comments on commit e974832

Please sign in to comment.