Skip to content

Commit 8fc540d

Browse files
feat(downstream): Only test downstreams from DOWNSTREAM_PKGS env variable (if set)
1 parent 9e782ec commit 8fc540d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test_downstream_projects.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ const pkgjson = JSON.parse(fs.readFileSync('package.json'));
1111

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

1516
function forEachDownstream(callback) {
1617
Object.keys(config).forEach(key => {
18+
if (DOWNSTREAM_PKGS.length && DOWNSTREAM_PKGS.indexOf(key) === -1) {
19+
console.log(key + ' not in DOWNSTREAM_PKGS, skipping...');
20+
return;
21+
}
22+
1723
const projectPath = path.resolve(DOWNSTREAMS_PATH, key);
1824
if (!fs.existsSync(projectPath)) {
1925
process.chdir(DOWNSTREAMS_PATH);
@@ -60,6 +66,13 @@ function installDeps() {
6066

6167
function runTests() {
6268
util._exec(`UPSTREAM_PKGS="${UPSTREAM_PKGS.join(',')}" npm test`);
69+
70+
const downstreamPkgJson = JSON.parse(fs.readFileSync('package.json'));
71+
const hasDownstreamTests = downstreamPkgJson.scripts && !!downstreamPkgJson.scripts['test:downstream'];
72+
73+
if (hasDownstreamTests) {
74+
util._exec(`UPSTREAM_PKGS="${UPSTREAM_PKGS.join(',')}" npm run test:downstream`);
75+
}
6376
}
6477

6578
makeWorkingCopy();

0 commit comments

Comments
 (0)