Merge pull request #6070 from serverless/deployment-skipping

Highlight skipping of deployments
This commit is contained in:
Philipp Muens 2019-05-06 10:12:47 +02:00 committed by GitHub
commit fc76d03dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 3 deletions

View File

@ -321,8 +321,18 @@ class CLI {
process.stdout.write(chalk.yellow('.'));
}
log(message, entity) {
this.consoleLog(`${entity || 'Serverless'}: ${chalk.yellow(`${message}`)}`);
log(message, entity, opts) {
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) {

View File

@ -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 () {
this.timeout(0);
const that = this;

View File

@ -124,7 +124,7 @@ module.exports = {
const message = [
'Service files not changed. Skipping deployment...',
].join('');
this.serverless.cli.log(message);
this.serverless.cli.log(message, 'Serverless', { color: 'orange' });
}
});
}