Skip to content

Commit 8271b5b

Browse files
Created utility methods that return just the commands that were executed or detailed information about each execution
1 parent d7ed622 commit 8271b5b

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

test/utils/mocks.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,39 @@
33
const files = require("./files");
44

55
const mocks = module.exports = {
6+
/**
7+
* Returns the `git` commands that were executed.
8+
*
9+
* @returns {string[]}
10+
*/
11+
git () {
12+
return mocks.gitDetails().map(mock => mock.cmd);
13+
},
14+
615
/**
716
* Returns information about each time `git` was executed.
817
*
918
* @returns {object[]}
1019
*/
11-
git () {
20+
gitDetails () {
1221
return mocks.all().filter(mock => mock.bin === "git");
1322
},
1423

24+
/**
25+
* Returns the `npm` commands that were executed.
26+
*
27+
* @returns {string[]}
28+
*/
29+
npm () {
30+
return mocks.npmDetails().map(mock => mock.cmd);
31+
},
32+
1533
/**
1634
* Returns information about each time `npm` was executed.
1735
*
1836
* @returns {object[]}
1937
*/
20-
npm () {
38+
npmDetails () {
2139
return mocks.all().filter(mock => mock.bin === "npm");
2240
},
2341

@@ -44,6 +62,8 @@ const mocks = module.exports = {
4462
array.push({
4563
bin,
4664

65+
args,
66+
4767
// Record the command that was executed
4868
cmd: bin + " " + args.map(quoteArgs).join(" "),
4969

0 commit comments

Comments
 (0)