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

Add config flags.logLevel #113

Merged
merged 3 commits into from
Jun 7, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# http://www.appveyor.com/docs/appveyor-yml
# http://www.appveyor.com/docs/lang/nodejs-iojs

branches:
# whitelist
only:
- master

environment:
matrix:
# node.js
Expand All @@ -15,7 +10,7 @@ environment:
- nodejs_version: "6"

install:
- npm -g install npm@latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to run into weird test runs on old node versions with this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phated The reason of removing this line is that the latest npm don’t support old versions of nodejs (< v4.x). This is needed if we are going to support gulp-cli on these old versions and use Appveyor for test on Windows.

Or we might be able to skip test on Windows about old versions of nodejs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not dropping 0.10.

Just install npm at a good version, like 2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phated If the “weird test” means using gulp-test-tool, since this tool is a thing to solve this issue on nodejs v0.10 on Windows, we can remove this tool if we skip test on Windows about old versions of nodejs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reply crossed with yours.

Just install npm at a good version, like 2

I got it. I checked our test succeeded with npm@2 now.

- npm -g install npm@2
- set PATH=%APPDATA%\npm;%PATH%
- ps: Install-Product node $env:nodejs_version
- npm install
Expand Down
1 change: 1 addition & 0 deletions lib/shared/config/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var copyProps = require('copy-props');
var fromTo = {
'flags.silent': 'silent',
'flags.continue': 'continue',
'flags.logLevel': 'logLevel',
};

function mergeConfigToCliFlags(opt, config) {
Expand Down
188 changes: 188 additions & 0 deletions test/config-flags-log-level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
'use strict';

var expect = require('expect');
var path = require('path');
var eraseTime = require('gulp-test-tools').eraseTime;
var runner = require('gulp-test-tools').gulpRunner;

describe('config: flag.logLevel', function() {

describe('log level 3 by default', function() {
it('Should output error log', function(done) {
runner({ verbose: false })
.gulp('--gulpfile x')
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(stdout).toEqual('');
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
done();
});
});

it('Should output warn log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'invalid-package.json');

runner({ verbose: false })
.gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(eraseTime(stdout)).toEqual(
'Verifying plugins in ' + packageJsonPath + '\n' +
'Blacklisted plugins found in this project:\n' +
'gulp-blink: deprecated. use \`blink` instead.\n');
expect(stderr).toEqual('');
done();
});
});

it('Should output info log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'valid-package.json');

runner({ verbose: false })
.gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toEqual(null);
expect(eraseTime(stdout)).toEqual(
'Verifying plugins in ' + packageJsonPath + '\n' +
'There are no blacklisted plugins in this project\n');
expect(stderr).toEqual('');
done(err);
});
});
});

describe('log level 1 by config `flags.logLevel`', function() {
var gulp = runner({ verbose: false })
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/L'))
.gulp;

it('Should output error log', function(done) {
gulp('--gulpfile x')
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(stdout).toEqual('');
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
done();
});
});

it('Should output warn log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'invalid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(stdout).toEqual('');
expect(stderr).toEqual('');
done();
});
});

it('Should output info log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'valid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toEqual(null);
expect(stdout).toEqual('');
expect(stderr).toEqual('');
done(err);
});
});
});

describe('log level 2 by config `flags.logLevel`', function() {
var gulp = runner({ verbose: false })
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/LL'))
.gulp;

it('Should output error log', function(done) {
gulp('--gulpfile x')
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(stdout).toEqual('');
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
done();
});
});

it('Should output warn log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'invalid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(eraseTime(stdout)).toEqual(
'Blacklisted plugins found in this project:\n' +
'gulp-blink: deprecated. use \`blink` instead.\n');
expect(stderr).toEqual('');
done();
});
});

it('Should output info log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'valid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toEqual(null);
expect(stdout).toEqual('');
expect(stderr).toEqual('');
done(err);
});
});
});

describe('log level 3 by config `flags.logLevel`', function() {
var gulp = runner({ verbose: false })
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/LLL'))
.gulp;

it('Should output error log', function(done) {
gulp('--gulpfile x')
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(stdout).toEqual('');
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
done();
});
});

it('Should output warn log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'invalid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toNotEqual(null);
expect(eraseTime(stdout)).toEqual(
'Verifying plugins in ' + packageJsonPath + '\n' +
'Blacklisted plugins found in this project:\n' +
'gulp-blink: deprecated. use \`blink` instead.\n');
expect(stderr).toEqual('');
done();
});
});

it('Should output info log', function(done) {
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
'valid-package.json');

gulp('--verify', packageJsonPath)
.run(function(err, stdout, stderr) {
expect(err).toEqual(null);
expect(eraseTime(stdout)).toEqual(
'Verifying plugins in ' + packageJsonPath + '\n' +
'There are no blacklisted plugins in this project\n');
expect(stderr).toEqual('');
done(err);
});
});
});
});
5 changes: 5 additions & 0 deletions test/fixtures/config/flags/logLevel/L/.gulp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"flags": {
"logLevel": 1
}
}
5 changes: 5 additions & 0 deletions test/fixtures/config/flags/logLevel/LL/.gulp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"flags": {
"logLevel": 2
}
}
5 changes: 5 additions & 0 deletions test/fixtures/config/flags/logLevel/LLL/.gulp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"flags": {
"logLevel": 3
}
}