Skip to content

Commit 66bd430

Browse files
feat(test:downstream): Support folding of output in travis ci
1 parent df92ad7 commit 66bd430

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test_downstream_projects.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fs = require('fs');
33
const path = require('path');
44
const tmp = require('tmp');
55
const shelljs = require('shelljs');
6+
const IS_TRAVIS = !!process.env.TRAVIS;
67

78
const yargs = require('yargs')
89
.option('workspace', {
@@ -12,6 +13,12 @@ const yargs = require('yargs')
1213

1314
const nodeCleanup = require('node-cleanup');
1415
const publishYalcPackage = require('./publish_yalc_package');
16+
const foldStart = (message) => {
17+
IS_TRAVIS && console.log('travis_fold:start:' + message);
18+
console.log(message);
19+
return () => IS_TRAVIS && console.log('travis_fold:end:' + message);
20+
};
21+
let foldEnd = () => null;
1522

1623
const util = require('./util');
1724
util.packageDir();
@@ -164,6 +171,8 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
164171

165172
const name = downstreamTreeNode.installDir;
166173

174+
foldEnd = foldStart(` ===> Running downstream tests: '${name}' <===`)
175+
167176
console.log(` ===> '${name}': prepping tests <===`);
168177
process.chdir(downstreamTreeNode.installDir);
169178

@@ -183,13 +192,16 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
183192
console.log(` ===> '${name}': Reverting working copy <===`);
184193
revertLocalChanges(downstreamTreeNode.installSource);
185194

195+
foldEnd();
186196

187197
const downstreamChildren = Object.keys(downstreamTreeNode.children || {});
188198
if (downstreamChildren.length) {
189199
const thisPkg = JSON.parse(fs.readFileSync('package.json')).name;
190200
const upstreams = upstreamPackages.concat(thisPkg);
191201

202+
foldEnd = foldStart(` ===> Local Yalc Publish: ${process.cwd()} <===`);
192203
localPublish(process.cwd());
204+
foldEnd();
193205

194206
downstreamChildren.forEach(child => {
195207
runDownstreamTests(child, upstreams, downstreamTreeNode.children[child], successLog);
@@ -200,17 +212,20 @@ function runDownstreamTests(key, upstreamPackages, downstreamTreeNode, successLo
200212
console.log(` ===> Creating .downstream_cache working directory <===`);
201213
makeDownstreamCache();
202214

203-
console.log(` ===> Publishing ${pkgjson.name} to yalc registry <===`);
215+
foldEnd = foldStart(` ===> Publishing ${pkgjson.name} to yalc registry <===`);
204216
localPublish();
217+
foldEnd();
205218

206-
console.log(` ===> Fetching downstream projects <===`);
219+
foldEnd = foldStart(` ===> Fetching downstream projects <===`);
207220
const tree = { children: {} };
208221
fetchDownstreamProjects(projects, "", tree.children);
222+
foldEnd();
209223

210224
if (yargs.argv.workspace) {
211-
console.log(` ===> Installing downstream dependencies <===`);
225+
foldEnd = foldStart(` ===> Installing downstream dependencies <===`);
212226
const downstreamDirs = getDownstreamInstallDirs(tree);
213227
installWorkspaceDependencies(downstreamDirs);
228+
foldEnd();
214229
}
215230

216231
console.log(` ===> Moving working directory to temp dir ${TEMP_DIR} <===`);

0 commit comments

Comments
 (0)