Skip to content

Commit

Permalink
feat(nx): add run-many
Browse files Browse the repository at this point in the history
This adds a run-many command to:

 - make more semantic sense for the --all option
 - to add the ability to specify specific projects to run

It also involves a quite substancial refactoring of affected.ts in order
to attempt reuse of the code in both commands
  • Loading branch information
mbriggs authored and vsavkin committed Nov 15, 2019
1 parent 949869e commit bebc71a
Show file tree
Hide file tree
Showing 16 changed files with 1,053 additions and 816 deletions.
13 changes: 4 additions & 9 deletions e2e/affected.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {
updateFile,
runCLI,
forEachCli,
supportUi,
newProject
supportUi
} from './utils';

let originalCIValue;
let originalCIValue: any;

forEachCli(() => {
/**
Expand Down Expand Up @@ -131,9 +130,7 @@ forEachCli(() => {
expect(buildParallel).toContain(`Running target build for projects:`);
expect(buildParallel).toContain(`- ${myapp}`);
expect(buildParallel).toContain(`- ${mypublishablelib}`);
expect(buildParallel).toContain(
'Running target "build" for affected projects succeeded'
);
expect(buildParallel).toContain('Running target "build" succeeded');

const buildExcluded = runCommand(
`npm run affected:build -- --files="libs/${mylib}/src/index.ts" --exclude ${myapp}`
Expand Down Expand Up @@ -240,9 +237,7 @@ forEachCli(() => {
const interpolatedTests = runCommand(
`npm run affected -- --target test --files="libs/${mylib}/src/index.ts" -- --jest-config {project.root}/jest.config.js`
);
expect(interpolatedTests).toContain(
`Running target \"test\" for affected projects succeeded`
);
expect(interpolatedTests).toContain(`Running target \"test\" succeeded`);
}, 1000000);
});
});
48 changes: 48 additions & 0 deletions e2e/run-many.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ensureProject, uniq, runCLI, forEachCli } from './utils';

let originalCIValue: any;

forEachCli(() => {
/**
* Setting CI=true makes it simpler to configure assertions around output, as there
* won't be any colors.
*/
beforeAll(() => {
originalCIValue = process.env.CI;
process.env.CI = 'true';
});

afterAll(() => {
process.env.CI = originalCIValue;
});

describe('Run Many', () => {
it('should build specific and all projects', () => {
ensureProject();
const mylib = uniq('mylib');
const mylib2 = uniq('mylib2');
const mylib3 = uniq('mylib3');
runCLI(`generate @nrwl/angular:lib ${mylib} --publishable`);
runCLI(`generate @nrwl/angular:lib ${mylib2} --publishable`);
runCLI(`generate @nrwl/angular:lib ${mylib3} --publishable`);

const buildParallel = runCLI(
`run-many --target=build --projects="${mylib},${mylib2}" --parallel`
);
expect(buildParallel).toContain(`Running target build for projects:`);
expect(buildParallel).toContain(`- ${mylib}`);
expect(buildParallel).toContain(`- ${mylib2}`);
expect(buildParallel).not.toContain(`- ${mylib3}`);
expect(buildParallel).toContain('Running target "build" succeeded');

const buildAllParallel = runCLI(
`run-many --target=build --all --parallel`
);
expect(buildAllParallel).toContain(`Running target build for projects:`);
expect(buildAllParallel).toContain(`- ${mylib}`);
expect(buildAllParallel).toContain(`- ${mylib2}`);
expect(buildAllParallel).toContain(`- ${mylib3}`);
expect(buildAllParallel).toContain('Running target "build" succeeded');
}, 1000000);
});
});
153 changes: 0 additions & 153 deletions packages/workspace/src/command-line/affected.spec.ts

This file was deleted.

0 comments on commit bebc71a

Please sign in to comment.