Skip to content

Commit bb4dd7d

Browse files
authored
fix(core): handle undefined properties in schemas with additionalProperties (nrwl#22426)
1 parent 81cf348 commit bb4dd7d

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

e2e/nx-run/src/run.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,27 @@ describe('Nx Running Tests', () => {
190190
expect(output).toContain(app);
191191
});
192192
});
193+
194+
it('should pass env option to nx:run-commands executor', () => {
195+
const mylib = uniq('mylib');
196+
runCLI(`generate @nx/js:lib ${mylib}`);
197+
198+
updateJson(`libs/${mylib}/project.json`, (c) => {
199+
c.targets['echo'] = {
200+
executor: 'nx:run-commands',
201+
options: {
202+
command: 'node -e "console.log(process.env.ONE)"',
203+
env: {
204+
ONE: 'TWO',
205+
},
206+
},
207+
};
208+
return c;
209+
});
210+
211+
const output = runCLI(`echo ${mylib}`);
212+
expect(output).toContain('TWO');
213+
});
193214
});
194215

195216
describe('Nx Bail', () => {

packages/nx/src/tasks-runner/task-orchestrator.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export class TaskOrchestrator {
351351
const temporaryOutputPath = this.cache.temporaryOutputPath(task);
352352
const streamOutput = shouldStreamOutput(task, this.initiatingProject);
353353

354-
const env = pipeOutput
354+
let env = pipeOutput
355355
? getEnvVariablesForTask(
356356
task,
357357
taskSpecificEnv,
@@ -403,6 +403,12 @@ export class TaskOrchestrator {
403403
relative(task.projectRoot ?? workspaceRoot, process.cwd()),
404404
process.env.NX_VERBOSE_LOGGING === 'true'
405405
);
406+
if (combinedOptions.env) {
407+
env = {
408+
...env,
409+
...combinedOptions.env,
410+
};
411+
}
406412
if (streamOutput) {
407413
const args = getPrintableCommandArgsForTask(task);
408414
output.logCommand(args.join(' '));

packages/nx/src/utils/params.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export function validateObject(
306306
) {
307307
Object.keys(opts).find((p) => {
308308
if (
309-
Object.keys(schema.properties).indexOf(p) === -1 &&
309+
Object.keys(schema.properties ?? {}).indexOf(p) === -1 &&
310310
(!schema.patternProperties ||
311311
!Object.keys(schema.patternProperties).some((pattern) =>
312312
new RegExp(pattern).test(p)

0 commit comments

Comments
 (0)