Skip to content

Commit

Permalink
feat(downstream): Only test downstreams from DOWNSTREAM_PKGS env vari…
Browse files Browse the repository at this point in the history
…able (if set)
  • Loading branch information
christopherthielen committed Dec 27, 2017
1 parent 9e782ec commit 8fc540d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test_downstream_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ const pkgjson = JSON.parse(fs.readFileSync('package.json'));

const DOWNSTREAMS_PATH = path.resolve(PKG_DIR, 'downstream_projects');
const UPSTREAM_PKGS = (process.env.UPSTREAM_PKGS || '').split(',').filter(x => x).concat(pkgjson.name);
const DOWNSTREAM_PKGS = (process.env.DOWNSTREAM_PKGS || '').split(',').filter(x => x);

function forEachDownstream(callback) {
Object.keys(config).forEach(key => {
if (DOWNSTREAM_PKGS.length && DOWNSTREAM_PKGS.indexOf(key) === -1) {
console.log(key + ' not in DOWNSTREAM_PKGS, skipping...');
return;
}

const projectPath = path.resolve(DOWNSTREAMS_PATH, key);
if (!fs.existsSync(projectPath)) {
process.chdir(DOWNSTREAMS_PATH);
Expand Down Expand Up @@ -60,6 +66,13 @@ function installDeps() {

function runTests() {
util._exec(`UPSTREAM_PKGS="${UPSTREAM_PKGS.join(',')}" npm test`);

const downstreamPkgJson = JSON.parse(fs.readFileSync('package.json'));
const hasDownstreamTests = downstreamPkgJson.scripts && !!downstreamPkgJson.scripts['test:downstream'];

if (hasDownstreamTests) {
util._exec(`UPSTREAM_PKGS="${UPSTREAM_PKGS.join(',')}" npm run test:downstream`);
}
}

makeWorkingCopy();
Expand Down

0 comments on commit 8fc540d

Please sign in to comment.