Skip to content

Commit

Permalink
chore: send warnings to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed May 5, 2021
1 parent 7a0f4d8 commit 99e87ff
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions packages/generators/src/addon-generator.ts
@@ -1,4 +1,3 @@
import { yellow } from 'colorette';
import fs from 'fs';
import path from 'path';
import Generator from 'yeoman-generator';
Expand Down Expand Up @@ -58,7 +57,7 @@ const addonGenerator = (

public async prompting(): Promise<void> {
if (!this.supportedTemplates.includes(this.template)) {
this.utils.logger.log(`${yellow(`${this.template} is not a valid template, please select one from below`)}`);
this.utils.logger.warn(`${this.template} is not a valid template, please select one from below`);

const { selectedTemplate } = await List(
this,
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/src/init-generator.ts
Expand Up @@ -58,7 +58,7 @@ export default class InitGenerator extends CustomGenerator {
}

if (!this.supportedTemplates.includes(this.template)) {
this.utils.logger.log(`${yellow(`${this.template} is not a valid template, please select one from below`)}`);
this.utils.logger.warn(`${this.template} is not a valid template, please select one from below`);

const { selectedTemplate } = await Question.List(
this,
Expand Down
2 changes: 1 addition & 1 deletion test/init/init.test.js
Expand Up @@ -112,7 +112,7 @@ describe('init command', () => {
const { stdout, stderr } = await runPromptWithAnswers(assetsPath, ['init', '--force', '--template=apple'], [`${ENTER}`]);

expect(stdout).toContain('Project has been initialised with webpack!');
expect(stdout).toContain('apple is not a valid template, please select one from below');
expect(stderr).toContain('apple is not a valid template, please select one from below');
expect(stderr).toContain('webpack.config.js');

// Test files
Expand Down
4 changes: 2 additions & 2 deletions test/loader/loader.test.js
Expand Up @@ -147,8 +147,8 @@ describe('loader command', () => {

it('should prompt on supplying an invalid template', async () => {
const assetsPath = await uniqueDirectoryForTest();
const { stdout } = await runPromptWithAnswers(assetsPath, ['loader', '--template=unknown']);
const { stderr } = await runPromptWithAnswers(assetsPath, ['loader', '--template=unknown']);

expect(stdout).toContain('unknown is not a valid template');
expect(stderr).toContain('unknown is not a valid template');
});
});
4 changes: 2 additions & 2 deletions test/plugin/plugin.test.js
Expand Up @@ -136,8 +136,8 @@ describe('plugin command', () => {

it('should prompt on supplying an invalid template', async () => {
const assetsPath = await uniqueDirectoryForTest();
const { stdout } = await runPromptWithAnswers(assetsPath, ['plugin', '--template=unknown']);
const { stderr } = await runPromptWithAnswers(assetsPath, ['plugin', '--template=unknown']);

expect(stdout).toContain('unknown is not a valid template');
expect(stderr).toContain('unknown is not a valid template');
});
});

0 comments on commit 99e87ff

Please sign in to comment.