Skip to content

Commit a120235

Browse files
committed
adding flag "p" to turn off the progress bar
1 parent 4e21cd9 commit a120235

4 files changed

Lines changed: 36 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Tutorials for catalog on sap.com http://go.sap.com/developer/tutorials.html",
55
"main": "README.MD",
66
"scripts": {
7-
"test": "node test.js -a"
7+
"test": "node test.js -pa"
88
},
99
"repository": {
1010
"type": "git",

test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const optionDefinitions = [
2525
{ name: 'wip', alias: 'w', type: Boolean },
2626
{ name: 'specific', alias: 's', type: Boolean },
2727
{ name: 'input', alias: 'i', type: String },
28-
{ name: 'file', alias: 'f', type: Boolean}
28+
{ name: 'file', alias: 'f', type: Boolean},
29+
{ name: 'progressbar', alias: 'p', type: Boolean}
2930
]
3031

3132
const options = commandLineArgs(optionDefinitions)
@@ -40,8 +41,13 @@ if (options.file){
4041
inquirerprompt.setShowfilename(true);
4142
}
4243

44+
//if p flag is set it turns off the progressbar
45+
if (options.progressbar){
46+
inquirerprompt.turnoffprogressbar(true);
47+
}
48+
4349
if (options.help){
44-
log.info("HELP: Your possibilities for the input: \n -h or --help for Help \n -f: to log all filenames, which get tested \n -a: for testing everything (including files, which aren't tutorials) \n -w & -t: for testing every tutorial in both folders \n -w: for testing all files in the work-in-progress folder \n -t: for testing all files in the tutorials folder \n -s: for dialog to choose specific tutorials \n -i: to give an filename behind with *\n to resctrict the scope: enter -w or/and -t");
50+
log.info("HELP: Your possibilities for the input: \n -h or --help for Help \n -f: to log all filenames, which get tested \n -a: for testing everything (including files, which aren't tutorials) \n -w & -t: for testing every tutorial in both folders \n -w: for testing all files in the work-in-progress folder \n -t: for testing all files in the tutorials folder \n -s: for dialog to choose specific tutorials \n -i: to give an filename behind with *\n to resctrict the scope: enter -w or/and -t \n -p: to turn off the progressbar ");
4551
}
4652

4753
else if (options.all){

test_modules/checkAll/check.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var log = require('color-log');
1212
var path = require('path');
1313
var ProgressBar = require('progress');
1414

15-
module.exports = function(files, callback) {
15+
module.exports = function(files, showprogressbar, callback) {
1616
console.log("\n");
1717

1818
//initialize ProgressBar
@@ -22,6 +22,8 @@ module.exports = function(files, callback) {
2222
total: (4 * files.length) + 2
2323
});
2424

25+
26+
2527
//initialize log for every test
2628
var logFilename = "";
2729
var logMdSpell = "";
@@ -40,18 +42,18 @@ module.exports = function(files, callback) {
4042
var cntNotCheckedDeadlink = 0;
4143

4244
var index = 0;
43-
bar.tick();
45+
if(showprogressbar){ bar.tick(); };
4446

4547
//read .spelling file
4648
readWhiteList(function() {
47-
bar.tick();
49+
if(showprogressbar){ bar.tick(); };
4850
//check every file
4951
files.forEach(function(file) {
5052

5153
//check Filenames
5254
var fname = path.basename(file);
5355
var filenameRes = checkFilename(fname, file);
54-
bar.tick();
56+
if(showprogressbar){ bar.tick(); };
5557
//build error log
5658
if (filenameRes !== null) {
5759
cntFilename++;
@@ -62,7 +64,7 @@ module.exports = function(files, callback) {
6264

6365
//check spelling
6466
mdspell(file, function(report) {
65-
bar.tick();
67+
if(showprogressbar){ bar.tick(); };
6668
var splitReport = report.split(/\r?\n/);
6769
if (splitReport.length >= 3) {
6870
//build error log
@@ -79,7 +81,7 @@ module.exports = function(files, callback) {
7981

8082
//readLines
8183
readLines(file, function(fileContent) {
82-
bar.tick();
84+
if(showprogressbar){ bar.tick(); };
8385
if (fileContent != null) {
8486
//check file content
8587
var lineIndex = 0;
@@ -103,7 +105,7 @@ module.exports = function(files, callback) {
103105

104106
//check links
105107
var x = checkDeadLink(fname, getLinks(fileContent), function(results) {
106-
bar.tick();
108+
if(showprogressbar){ bar.tick(); };
107109
index++;
108110
if (results != null) {
109111
checkedLinks += results.count;

test_modules/prompt/inquirerprompt.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ var setShowfilename = function(value){
2323
showfilenames = value;
2424
}
2525

26+
var showprogressbar = true;
27+
28+
var turnoffprogressbar = function(value){
29+
if (value){
30+
showprogressbar = false;
31+
}
32+
}
33+
2634
//"main function" -> reacts on the user input from commands
2735
var ask = function (array){
2836
inquirer.prompt(array).then(function(results) {
@@ -168,7 +176,7 @@ var alltutorials = function (){
168176
console.log(resultarray);
169177
}
170178
//console.log(resultarray.length);
171-
checkjs(resultarray);
179+
checkjs(resultarray, showprogressbar);
172180
}
173181

174182
var allfiles = function (){
@@ -196,7 +204,7 @@ var allfiles = function (){
196204
}
197205

198206
//console.log(resultarray.length);
199-
checkjs(resultarray);
207+
checkjs(resultarray, showprogressbar);
200208
}
201209

202210
//function to build the results array with all files of the wip folder in case the user wants to test all wip-tutorials
@@ -208,7 +216,7 @@ var wip = function (){
208216
if (showfilenames){
209217
console.log(resultarray);
210218
}
211-
checkjs(resultarray);
219+
checkjs(resultarray, showprogressbar);
212220
}
213221

214222
//function to build the results array with all files of the tutorial folder in case the user wants to test all tutorials
@@ -220,7 +228,7 @@ var tutorials = function (){
220228
if (showfilenames){
221229
console.log(resultarray);
222230
}
223-
checkjs(resultarray);
231+
checkjs(resultarray, showprogressbar);
224232
}
225233

226234
//function to build the next interacive command in case the user wants to type in the filenames of tutorials
@@ -253,7 +261,7 @@ var singletutorialsselected = function (results){
253261
if (showfilenames){
254262
console.log(resultarray);
255263
}
256-
checkjs(resultarray);
264+
checkjs(resultarray, showprogressbar);
257265
}
258266

259267

@@ -279,7 +287,7 @@ var tutorialsgrouptutorials = function (results){
279287
if (showfilenames){
280288
console.log(resultarray);
281289
}
282-
checkjs(resultarray);
290+
checkjs(resultarray, showprogressbar);
283291
}
284292

285293

@@ -305,7 +313,7 @@ var wipgrouptutorials = function (results){
305313
if (showfilenames){
306314
console.log(resultarray);
307315
}
308-
checkjs(resultarray);
316+
checkjs(resultarray, showprogressbar);
309317
}
310318

311319

@@ -354,7 +362,7 @@ var allgrouptutorials = function (results){
354362
if (showfilenames){
355363
console.log(resultarray);
356364
}
357-
checkjs(resultarray);
365+
checkjs(resultarray, showprogressbar);
358366

359367

360368
}
@@ -376,5 +384,6 @@ module.exports = {
376384
tutorialsgrouptutorials: tutorialsgrouptutorials,
377385
wipgrouptutorials: wipgrouptutorials,
378386
readallfilenames: readallfilenames,
379-
setShowfilename: setShowfilename
387+
setShowfilename: setShowfilename,
388+
turnoffprogressbar: turnoffprogressbar
380389
}

0 commit comments

Comments
 (0)