diff --git a/lib/actions-oclif/ssh.ts b/lib/actions-oclif/ssh.ts index f9250ee2..23541f28 100644 --- a/lib/actions-oclif/ssh.ts +++ b/lib/actions-oclif/ssh.ts @@ -309,7 +309,7 @@ export default class NoteCmd extends Command { // and parse the output, looking for a specific // container const childProcess = await import('child_process'); - const escapeRegex = await import('lodash/escapeRegExp'); + const { escapeRegExp } = await import('lodash'); const { which } = await import('../utils/helpers'); const { deviceContainerEngineBinary } = await import( '../utils/device/ssh' @@ -349,7 +349,7 @@ export default class NoteCmd extends Command { }); const lines = containers.split('\n'); - const regex = new RegExp(`\\/?${escapeRegex(serviceName)}_\\d+_\\d+`); + const regex = new RegExp(`\\/?${escapeRegExp(serviceName)}_\\d+_\\d+`); for (const container of lines) { const [cId, name] = container.split(' '); if (regex.test(name)) { diff --git a/lib/utils/device/ssh.ts b/lib/utils/device/ssh.ts index 4d64f4df..8cc155fd 100644 --- a/lib/utils/device/ssh.ts +++ b/lib/utils/device/ssh.ts @@ -29,7 +29,7 @@ export const deviceContainerEngineBinary = `$(if [ -f /usr/bin/balena ]; then ec export async function performLocalDeviceSSH( opts: DeviceSSHOpts, ): Promise { - const reduce = await import('lodash/reduce'); + const { escapeRegExp, reduce } = await import('lodash'); const { spawnSshAndExitOnError } = await import('../ssh'); const { ExpectedError } = await import('../../errors'); @@ -44,13 +44,12 @@ export async function performLocalDeviceSSH( // allows the user to choose the correct container const Docker = await import('dockerode'); - const escapeRegex = await import('lodash/escapeRegExp'); const docker = new Docker({ host: opts.address, port: 2375, }); - const regex = new RegExp(`\\/?${escapeRegex(opts.service)}_\\d+_\\d+`); + const regex = new RegExp(`\\/?${escapeRegExp(opts.service)}_\\d+_\\d+`); const nameRegex = /\/?([a-zA-Z0-9_]+)_\d+_\d+/; let allContainers: ContainerInfo[]; try {