mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Merge pull request #6070 from serverless/deployment-skipping
Highlight skipping of deployments
This commit is contained in:
commit
fc76d03dbc
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user