Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit dc12508

Browse files
ehmickykodiakhq[bot]
andauthoredFeb 8, 2022
fix: fix shellUtils stubbing with ES modules (#983)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent fe96bc0 commit dc12508

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed
 

‎src/runtimes/go/builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { promises as fs } from 'fs'
22
import { basename } from 'path'
33

4-
import { runCommand } from '../../utils/shell'
4+
import { shellUtils } from '../../utils/shell'
55
import type { RuntimeName } from '../runtime'
66

77
const build = async ({ destPath, mainFile, srcDir }: { destPath: string; mainFile: string; srcDir: string }) => {
88
const functionName = basename(srcDir)
99

1010
try {
11-
await runCommand('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
11+
await shellUtils.runCommand('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
1212
cwd: srcDir,
1313
env: {
1414
CGO_ENABLED: '0',

‎src/runtimes/rust/builder.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import tmp from 'tmp-promise'
55
import toml from 'toml'
66

77
import { FunctionConfig } from '../../config'
8-
import { runCommand } from '../../utils/shell'
8+
import { shellUtils } from '../../utils/shell'
99
import type { RuntimeName } from '../runtime'
1010

1111
import { CargoManifest } from './cargo_manifest'
@@ -55,7 +55,7 @@ const cargoBuild = async ({
5555
targetDirectory: string
5656
}) => {
5757
try {
58-
await runCommand('cargo', ['build', '--target', BUILD_TARGET, '--release'], {
58+
await shellUtils.runCommand('cargo', ['build', '--target', BUILD_TARGET, '--release'], {
5959
cwd: srcDir,
6060
env: {
6161
CARGO_TARGET_DIR: targetDirectory,
@@ -79,7 +79,7 @@ const cargoBuild = async ({
7979

8080
const checkRustToolchain = async () => {
8181
try {
82-
await runCommand('cargo', ['-V'])
82+
await shellUtils.runCommand('cargo', ['-V'])
8383

8484
return true
8585
} catch {
@@ -113,8 +113,8 @@ let toolchainInstallation: Promise<void>
113113
// `BUILD_TARGET`. The Promise is saved to `toolchainInstallation`, so
114114
// that we run the command just once for multiple Rust functions.
115115
const installToolchain = async () => {
116-
await runCommand('rustup', ['default', 'stable'])
117-
await runCommand('rustup', ['target', 'add', BUILD_TARGET])
116+
await shellUtils.runCommand('rustup', ['default', 'stable'])
117+
await shellUtils.runCommand('rustup', ['target', 'add', BUILD_TARGET])
118118
}
119119

120120
const installToolchainOnce = () => {

‎src/utils/shell.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
import execa from 'execa'
22

3-
// eslint-disable-next-line unicorn/prefer-export-from
4-
export { execa as runCommand }
3+
export const shellUtils = { runCommand: execa }

‎tests/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require('source-map-support').install()
2222
// We must require this file first because we need to stub it before the main
2323
// functions are required.
2424
// eslint-disable-next-line import/order
25-
const shellUtils = require('../dist/utils/shell')
25+
const { shellUtils } = require('../dist/utils/shell')
2626

2727
const shellUtilsStub = sinon.stub(shellUtils, 'runCommand')
2828

1 commit comments

Comments
 (1)

github-actions[bot] commented on Feb 8, 2022

@github-actions[bot]
Contributor

⏱ Benchmark results

largeDepsEsbuild: 7.5s

largeDepsZisi: 56.9s

This repository has been archived.