MCPcopy
hub / github.com/shelljs/shx / cli

Function cli

test/specs/cli.js:21–45  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

19
20// Run the cli with args as argv
21const cli = (...args) => {
22 mocks.init();
23 const stdin = mocks.stdin();
24
25 let code;
26 try {
27 code = shx.call(stdin, ['', '', ...args]);
28 } catch (e) {
29 if (Object.prototype.hasOwnProperty.call(e, 'code')) {
30 // Shx is returning an error with a specified code
31 code = e.code;
32 } else {
33 // Shx is throwing an exception
34 throw e;
35 }
36 } finally {
37 mocks.restore();
38 }
39
40 return {
41 code,
42 stdout: mocks.stdout(),
43 stderr: mocks.stderr(),
44 };
45};
46
47describe('cli', () => {
48 beforeEach(() => {

Callers 1

cli.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected