MCPcopy Index your code
hub / github.com/serverless/serverless / mkCommand

Function mkCommand

packages/sf-core/tests/python/test.js:58–85  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

56
57const mkCommand =
58 (cmd) =>
59 (args, options = {}) => {
60 options['env'] = Object.assign(
61 { SERVERLESS_PLATFORM_STAGE: 'dev' },
62 process.env,
63 options['env'],
64 )
65 const { error, stdout, stderr, status } = crossSpawn.sync(
66 cmd,
67 args,
68 options,
69 )
70 if (error && !options['noThrow']) {
71 console.error(`Error running: ${quote([cmd, ...args])}`)
72 throw error
73 }
74 if (status && !options['noThrow']) {
75 console.error('STDOUT: ', stdout.toString())
76 console.error('STDERR: ', stderr.toString())
77 throw new Error(
78 `${quote([cmd, ...args])} failed with status code ${status}`,
79 )
80 }
81 return {
82 stdout: stdout && stdout.toString().trim(),
83 stderr: stderr && stderr.toString().trim(),
84 }
85 }
86
87const sls = mkCommand('sls')
88const git = mkCommand('git')

Callers 1

test.jsFile · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…