Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight skipping of deployments #6070

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/classes/CLI.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -321,8 +321,18 @@ class CLI {
process.stdout.write(chalk.yellow('.')); process.stdout.write(chalk.yellow('.'));
} }


log(message, entity) { log(message, entity, opts) {
this.consoleLog(`${entity || 'Serverless'}: ${chalk.yellow(`${message}`)}`); const underline = opts ? opts.underline : false;
const bold = opts ? opts.bold : false;
const color = opts ? opts.color : null;

let print = chalk.yellow;

if (color) print = chalk.keyword(color);
if (underline) print = print.underline;
if (bold) print = print.bold;

this.consoleLog(`${entity || 'Serverless'}: ${print(message)}`);
} }


consoleLog(message) { consoleLog(message) {
Expand Down
59 changes: 59 additions & 0 deletions lib/classes/CLI.test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -547,6 +547,65 @@ describe('CLI', () => {
}); });
}); });


describe('#log', () => {
let consoleLogSpy;

beforeEach(() => {
cli = new CLI(serverless);
consoleLogSpy = sinon.spy(cli, 'consoleLog');
});

afterEach(() => {
cli.consoleLog.restore();
});

it('should log messages', () => {
const msg = 'Hello World!';

cli.log(msg);

expect(consoleLogSpy.callCount).to.equal(1);
expect(consoleLogSpy.firstCall.args[0]).to.equal('Serverless: Hello World!');
});

it('should support different entities', () => {
const msg = 'Hello World!';
const entity = 'Entity';

cli.log(msg, entity);

expect(consoleLogSpy.callCount).to.equal(1);
expect(consoleLogSpy.firstCall.args[0]).to.equal('Entity: Hello World!');
});

// NOTE: Here we're just testing that it won't break
it('should support logging options', () => {
const msg = 'Hello World!';
const opts = {
color: 'orange',
bold: true,
underline: true,
};

cli.log(msg, 'Serverless', opts);

expect(consoleLogSpy.callCount).to.equal(1);
expect(consoleLogSpy.firstCall.args[0]).to.equal('Serverless: Hello World!');
});

it('should ignore invalid logging options', () => {
const msg = 'Hello World!';
const opts = {
invalid: 'option',
};

cli.log(msg, 'Serverless', opts);

expect(consoleLogSpy.callCount).to.equal(1);
expect(consoleLogSpy.firstCall.args[0]).to.equal('Serverless: Hello World!');
});
});

describe('Integration tests', function () { describe('Integration tests', function () {
this.timeout(0); this.timeout(0);
const that = this; const that = this;
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/deploy/lib/checkForChanges.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = {
const message = [ const message = [
'Service files not changed. Skipping deployment...', 'Service files not changed. Skipping deployment...',
].join(''); ].join('');
this.serverless.cli.log(message); this.serverless.cli.log(message, 'Serverless', { color: 'orange' });
} }
}); });
} }
Expand Down