Skip to content

Commit

Permalink
fix(core): handle undefined properties in schemas with additionalProp…
Browse files Browse the repository at this point in the history
…erties (#22426)
  • Loading branch information
MaxKless authored Mar 27, 2024
1 parent 81cf348 commit bb4dd7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
21 changes: 21 additions & 0 deletions e2e/nx-run/src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@ describe('Nx Running Tests', () => {
expect(output).toContain(app);
});
});

it('should pass env option to nx:run-commands executor', () => {
const mylib = uniq('mylib');
runCLI(`generate @nx/js:lib ${mylib}`);

updateJson(`libs/${mylib}/project.json`, (c) => {
c.targets['echo'] = {
executor: 'nx:run-commands',
options: {
command: 'node -e "console.log(process.env.ONE)"',
env: {
ONE: 'TWO',
},
},
};
return c;
});

const output = runCLI(`echo ${mylib}`);
expect(output).toContain('TWO');
});
});

describe('Nx Bail', () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/nx/src/tasks-runner/task-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class TaskOrchestrator {
const temporaryOutputPath = this.cache.temporaryOutputPath(task);
const streamOutput = shouldStreamOutput(task, this.initiatingProject);

const env = pipeOutput
let env = pipeOutput
? getEnvVariablesForTask(
task,
taskSpecificEnv,
Expand Down Expand Up @@ -403,6 +403,12 @@ export class TaskOrchestrator {
relative(task.projectRoot ?? workspaceRoot, process.cwd()),
process.env.NX_VERBOSE_LOGGING === 'true'
);
if (combinedOptions.env) {
env = {
...env,
...combinedOptions.env,
};
}
if (streamOutput) {
const args = getPrintableCommandArgsForTask(task);
output.logCommand(args.join(' '));
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/utils/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export function validateObject(
) {
Object.keys(opts).find((p) => {
if (
Object.keys(schema.properties).indexOf(p) === -1 &&
Object.keys(schema.properties ?? {}).indexOf(p) === -1 &&
(!schema.patternProperties ||
!Object.keys(schema.patternProperties).some((pattern) =>
new RegExp(pattern).test(p)
Expand Down

0 comments on commit bb4dd7d

Please sign in to comment.