Skip to content

Commit 7f0b050

Browse files
sttkphated
authored andcommitted
New: Add config flags.logLevel (closes #110) (#113)
1 parent 4c49f4a commit 7f0b050

File tree

6 files changed

+205
-6
lines changed

6 files changed

+205
-6
lines changed

appveyor.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# http://www.appveyor.com/docs/appveyor-yml
22
# http://www.appveyor.com/docs/lang/nodejs-iojs
33

4-
branches:
5-
# whitelist
6-
only:
7-
- master
8-
94
environment:
105
matrix:
116
# node.js
@@ -15,7 +10,7 @@ environment:
1510
- nodejs_version: "6"
1611

1712
install:
18-
- npm -g install npm@latest
13+
- npm -g install npm@2
1914
- set PATH=%APPDATA%\npm;%PATH%
2015
- ps: Install-Product node $env:nodejs_version
2116
- npm install

lib/shared/config/cli-flags.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var copyProps = require('copy-props');
55
var fromTo = {
66
'flags.silent': 'silent',
77
'flags.continue': 'continue',
8+
'flags.logLevel': 'logLevel',
89
};
910

1011
function mergeConfigToCliFlags(opt, config) {

test/config-flags-log-level.js

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
'use strict';
2+
3+
var expect = require('expect');
4+
var path = require('path');
5+
var eraseTime = require('gulp-test-tools').eraseTime;
6+
var runner = require('gulp-test-tools').gulpRunner;
7+
8+
describe('config: flag.logLevel', function() {
9+
10+
describe('log level 3 by default', function() {
11+
it('Should output error log', function(done) {
12+
runner({ verbose: false })
13+
.gulp('--gulpfile x')
14+
.run(function(err, stdout, stderr) {
15+
expect(err).toNotEqual(null);
16+
expect(stdout).toEqual('');
17+
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
18+
done();
19+
});
20+
});
21+
22+
it('Should output warn log', function(done) {
23+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
24+
'invalid-package.json');
25+
26+
runner({ verbose: false })
27+
.gulp('--verify', packageJsonPath)
28+
.run(function(err, stdout, stderr) {
29+
expect(err).toNotEqual(null);
30+
expect(eraseTime(stdout)).toEqual(
31+
'Verifying plugins in ' + packageJsonPath + '\n' +
32+
'Blacklisted plugins found in this project:\n' +
33+
'gulp-blink: deprecated. use \`blink` instead.\n');
34+
expect(stderr).toEqual('');
35+
done();
36+
});
37+
});
38+
39+
it('Should output info log', function(done) {
40+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
41+
'valid-package.json');
42+
43+
runner({ verbose: false })
44+
.gulp('--verify', packageJsonPath)
45+
.run(function(err, stdout, stderr) {
46+
expect(err).toEqual(null);
47+
expect(eraseTime(stdout)).toEqual(
48+
'Verifying plugins in ' + packageJsonPath + '\n' +
49+
'There are no blacklisted plugins in this project\n');
50+
expect(stderr).toEqual('');
51+
done(err);
52+
});
53+
});
54+
});
55+
56+
describe('log level 1 by config `flags.logLevel`', function() {
57+
var gulp = runner({ verbose: false })
58+
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/L'))
59+
.gulp;
60+
61+
it('Should output error log', function(done) {
62+
gulp('--gulpfile x')
63+
.run(function(err, stdout, stderr) {
64+
expect(err).toNotEqual(null);
65+
expect(stdout).toEqual('');
66+
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
67+
done();
68+
});
69+
});
70+
71+
it('Should output warn log', function(done) {
72+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
73+
'invalid-package.json');
74+
75+
gulp('--verify', packageJsonPath)
76+
.run(function(err, stdout, stderr) {
77+
expect(err).toNotEqual(null);
78+
expect(stdout).toEqual('');
79+
expect(stderr).toEqual('');
80+
done();
81+
});
82+
});
83+
84+
it('Should output info log', function(done) {
85+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
86+
'valid-package.json');
87+
88+
gulp('--verify', packageJsonPath)
89+
.run(function(err, stdout, stderr) {
90+
expect(err).toEqual(null);
91+
expect(stdout).toEqual('');
92+
expect(stderr).toEqual('');
93+
done(err);
94+
});
95+
});
96+
});
97+
98+
describe('log level 2 by config `flags.logLevel`', function() {
99+
var gulp = runner({ verbose: false })
100+
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/LL'))
101+
.gulp;
102+
103+
it('Should output error log', function(done) {
104+
gulp('--gulpfile x')
105+
.run(function(err, stdout, stderr) {
106+
expect(err).toNotEqual(null);
107+
expect(stdout).toEqual('');
108+
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
109+
done();
110+
});
111+
});
112+
113+
it('Should output warn log', function(done) {
114+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
115+
'invalid-package.json');
116+
117+
gulp('--verify', packageJsonPath)
118+
.run(function(err, stdout, stderr) {
119+
expect(err).toNotEqual(null);
120+
expect(eraseTime(stdout)).toEqual(
121+
'Blacklisted plugins found in this project:\n' +
122+
'gulp-blink: deprecated. use \`blink` instead.\n');
123+
expect(stderr).toEqual('');
124+
done();
125+
});
126+
});
127+
128+
it('Should output info log', function(done) {
129+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
130+
'valid-package.json');
131+
132+
gulp('--verify', packageJsonPath)
133+
.run(function(err, stdout, stderr) {
134+
expect(err).toEqual(null);
135+
expect(stdout).toEqual('');
136+
expect(stderr).toEqual('');
137+
done(err);
138+
});
139+
});
140+
});
141+
142+
describe('log level 3 by config `flags.logLevel`', function() {
143+
var gulp = runner({ verbose: false })
144+
.basedir(path.join(__dirname, 'fixtures/config/flags/logLevel/LLL'))
145+
.gulp;
146+
147+
it('Should output error log', function(done) {
148+
gulp('--gulpfile x')
149+
.run(function(err, stdout, stderr) {
150+
expect(err).toNotEqual(null);
151+
expect(stdout).toEqual('');
152+
expect(eraseTime(stderr)).toEqual('No gulpfile found\n');
153+
done();
154+
});
155+
});
156+
157+
it('Should output warn log', function(done) {
158+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
159+
'invalid-package.json');
160+
161+
gulp('--verify', packageJsonPath)
162+
.run(function(err, stdout, stderr) {
163+
expect(err).toNotEqual(null);
164+
expect(eraseTime(stdout)).toEqual(
165+
'Verifying plugins in ' + packageJsonPath + '\n' +
166+
'Blacklisted plugins found in this project:\n' +
167+
'gulp-blink: deprecated. use \`blink` instead.\n');
168+
expect(stderr).toEqual('');
169+
done();
170+
});
171+
});
172+
173+
it('Should output info log', function(done) {
174+
var packageJsonPath = path.resolve(__dirname, 'fixtures/packages',
175+
'valid-package.json');
176+
177+
gulp('--verify', packageJsonPath)
178+
.run(function(err, stdout, stderr) {
179+
expect(err).toEqual(null);
180+
expect(eraseTime(stdout)).toEqual(
181+
'Verifying plugins in ' + packageJsonPath + '\n' +
182+
'There are no blacklisted plugins in this project\n');
183+
expect(stderr).toEqual('');
184+
done(err);
185+
});
186+
});
187+
});
188+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"flags": {
3+
"logLevel": 1
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"flags": {
3+
"logLevel": 2
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"flags": {
3+
"logLevel": 3
4+
}
5+
}

0 commit comments

Comments
 (0)