Skip to content

Commit

Permalink
feat(verbose): add verbose yarn output (#1037)
Browse files Browse the repository at this point in the history
refs #1036 
- use verbose option with yarn when verbose is enabled for main command
  • Loading branch information
ErisDS authored and acburdine committed Nov 4, 2019
1 parent 5572332 commit 223c29f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/tasks/yarn-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ module.exports = function yarnInstall(ui, zipFile) {
tasks.push({
title: 'Installing dependencies',
task: (ctx) => {
const observable = yarn(['install', '--no-emoji', '--no-progress'], {
const yarnOpts = ['install', '--no-emoji', '--no-progress'];
if (ui.verbose) {
yarnOpts.push('--verbose');
}
const observable = yarn(yarnOpts, {
cwd: ctx.installPath,
env: {NODE_ENV: 'production'},
observe: true
Expand Down
33 changes: 33 additions & 0 deletions test/unit/tasks/yarn-install-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@ describe('Unit: Tasks > yarn-install', function () {
});
});

it('verbose option', function () {
const yarnStub = sinon.stub().returns(new Observable(o => o.complete()));
const yarnInstall = proxyquire(modulePath, {
'../utils/yarn': yarnStub
});
const subTasks = yarnInstall.subTasks;
const ctx = {installPath: '/var/www/ghost/versions/1.5.0'};
const listrStub = sinon.stub().callsFake((tasks) => {
expect(tasks).to.have.length(3);

return Promise.each(tasks, (task) => {
const result = task.task(ctx);
return isObservable(result) ? result.toPromise() : result;
});
});

const distTaskStub = sinon.stub(subTasks, 'dist').resolves();
const downloadTaskStub = sinon.stub(subTasks, 'download');

return yarnInstall({listr: listrStub, verbose: true}).then(() => {
expect(listrStub.calledOnce).to.be.true;
expect(distTaskStub.calledOnce).to.be.true;
expect(downloadTaskStub.calledOnce).to.be.true;
expect(yarnStub.calledOnce).to.be.true;
expect(yarnStub.args[0][0]).to.deep.equal(['install', '--no-emoji', '--no-progress', '--verbose']);
expect(yarnStub.args[0][1]).to.deep.equal({
cwd: '/var/www/ghost/versions/1.5.0',
env: {NODE_ENV: 'production'},
observe: true
});
});
});

it('base function can take zip file', function () {
const decompressStub = sinon.stub().resolves();
const listrStub = sinon.stub().resolves();
Expand Down

0 comments on commit 223c29f

Please sign in to comment.