Skip to content

Commit 858f415

Browse files
committed
Update dscan.d
1 parent f0f353c commit 858f415

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

dscan.d

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public auto main(string[] args)
9191

9292
retval |= runDscanner(engines, expressions, target);
9393
retval |= buildDocs();
94+
retval |= buildDocs("unittest");
9495

9596
writeln();
9697
writeln(i"[+] done, return $(retval)");
@@ -167,6 +168,7 @@ auto runDscanner(
167168
import std.array : Appender;
168169
import std.datetime.stopwatch : StopWatch;
169170
import std.process : execute;
171+
import std.range : walkLength;
170172
import std.string : strip;
171173

172174
Appender!(string[]) uncaughtLines;
@@ -220,6 +222,7 @@ auto runDscanner(
220222
if (!atLeastOneMatch) uncaughtLines.put(line);
221223
}
222224

225+
immutable numLines = range.walkLength();
223226
int retval;
224227

225228
if (uncaughtLines[].length)
@@ -229,20 +232,21 @@ auto runDscanner(
229232
writeln();
230233
uncaughtLines[].each!writeln();
231234
writeln();
235+
writeln(i"[!] $(numLines) line(s) caught by regex");
232236
writeln(i"[!] $(uncaughtLines[].length) line(s) got past regex, retval becomes $(result.status)");
233237
retval = result.status;
234238
}
235239
else
236240
{
237-
writeln("[!] all output caught by regex");
241+
writeln(i"[!] all $(numLines) line(s) caught by regex");
238242
}
239243

240244
foreach (immutable i, engineMatched; engineMatches)
241245
{
242246
if (!engineMatched)
243247
{
244248
writeln(i`[!] dead expression: "$(expressions[i])"`);
245-
retval |= 1;
249+
//retval |= 1;
246250
}
247251
}
248252

@@ -254,38 +258,47 @@ auto runDscanner(
254258
/++
255259
Simply invokes `dub build -b docs`.`
256260
261+
Params:
262+
buildConfiguration = Optional dub build configuration to build docs with.
263+
257264
Returns:
258265
The shell return value of the command run.
259266
+/
260-
auto buildDocs()
267+
auto buildDocs(const string buildConfiguration = string.init)
261268
{
262269
import std.datetime.stopwatch : StopWatch;
263270
import std.process : execute;
264271
import std.string : strip;
265272

266273
StopWatch sw;
267274

268-
static immutable command =
275+
auto command =
269276
[
270277
"dub",
271278
"build",
272279
"-b",
273280
"docs",
274-
"-c",
275-
"dev",
276281
"--nodeps",
277282
//"--vquiet",
278283
];
279284

285+
if (buildConfiguration.length)
286+
{
287+
command ~= [ "-c", buildConfiguration ];
288+
}
289+
290+
immutable buildConfigString = buildConfiguration.length ?
291+
" (" ~ buildConfiguration ~ ')' :
292+
string.init;
280293

281294
writeln();
282-
writeln("[+] building docs...");
295+
writeln(i"[+] building docs$(buildConfigString)...");
283296

284297
sw.start();
285298
const result = execute(command);
286299
sw.stop();
287300

288-
writeln(i"[!] docs built in $(sw.peek), retval $(result.status)");
301+
writeln(i"[!] built in $(sw.peek), retval $(result.status)");
289302
writeln();
290303
writeln(result.output.strip());
291304

0 commit comments

Comments
 (0)