Skip to content

Commit

Permalink
chore(core): fix outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Oct 11, 2023
1 parent af94cfa commit 0eb4cae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion e2e/angular-core/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const angularV1Json = (appName: string) => `{
},
"test": {
"builder": "@nx/jest:jest",
"outputs": ["coverage${appName}"],
"outputs": ["{workspaceRoot}/coverage${appName}"],
"options": {
"jestConfig": "${appName}/jest.config.ts",
"passWithNoTests": true
Expand Down
2 changes: 1 addition & 1 deletion e2e/next-core/src/next-webpack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('Next.js Webpack', () => {
updateJson(join('apps', appName, 'project.json'), (json) => {
json.targets.build = {
command: 'npx next build',
outputs: [`apps/${appName}/.next`],
outputs: [`{projectRoot}/.next`],
options: {
cwd: `apps/${appName}`,
},
Expand Down
4 changes: 2 additions & 2 deletions e2e/nx-run/src/invoke-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe('Invoke Runner', () => {
async function main(){
const r = await initTasksRunner({});
await r.invoke({tasks: [{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, overrides: {__overrides_unparsed__: ''}}]});
await r.invoke({tasks: [{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, overrides: {__overrides_unparsed__: ''}}]});
await r.invoke({tasks: [{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, outputs: [], overrides: {__overrides_unparsed__: ''}}]});
await r.invoke({tasks: [{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, outputs: [], overrides: {__overrides_unparsed__: ''}}]});
}
main().then(q => {
Expand Down
9 changes: 9 additions & 0 deletions packages/nx/src/tasks-runner/init-tasks-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Task, TaskGraph } from '../config/task-graph';
import { invokeTasksRunner } from './run-command';
import { InvokeRunnerTerminalOutputLifeCycle } from './life-cycles/invoke-runner-terminal-output-life-cycle';
import { performance } from 'perf_hooks';
import { getOutputs } from './utils';

export async function initTasksRunner(nxArgs: NxArgs) {
performance.mark('init-local');
Expand All @@ -21,6 +22,14 @@ export async function initTasksRunner(nxArgs: NxArgs) {
parallel: number;
}): Promise<{ status: number; taskGraph: TaskGraph }> => {
performance.mark('code-loading:end');

// TODO: This polyfills the outputs if someone doesn't pass a task with outputs. Remove this in Nx 18
opts.tasks.forEach((t) => {
if (!t.outputs) {
t.outputs = getOutputs(projectGraph.nodes, t.target, t.overrides);
}
});

const lifeCycle = new InvokeRunnerTerminalOutputLifeCycle(opts.tasks);

const taskGraph = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('<%=propertyName%>Hasher', () => {
project: 'proj',
target: 'target'
},
overrides: {}
overrides: {},
outputs: []
}, {
hasher: mockHasher
} as unknown as HasherContext)
Expand Down

0 comments on commit 0eb4cae

Please sign in to comment.