Merge pull request #1898 from balena-io/import-lodash

Stop importing specific lodash files
This commit is contained in:
bulldozer-balena[bot] 2020-06-30 13:35:11 +00:00 committed by GitHub
commit a252a550ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -309,7 +309,7 @@ export default class NoteCmd extends Command {
// and parse the output, looking for a specific // and parse the output, looking for a specific
// container // container
const childProcess = await import('child_process'); const childProcess = await import('child_process');
const escapeRegex = await import('lodash/escapeRegExp'); const { escapeRegExp } = await import('lodash');
const { which } = await import('../utils/helpers'); const { which } = await import('../utils/helpers');
const { deviceContainerEngineBinary } = await import( const { deviceContainerEngineBinary } = await import(
'../utils/device/ssh' '../utils/device/ssh'
@ -349,7 +349,7 @@ export default class NoteCmd extends Command {
}); });
const lines = containers.split('\n'); 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) { for (const container of lines) {
const [cId, name] = container.split(' '); const [cId, name] = container.split(' ');
if (regex.test(name)) { if (regex.test(name)) {

View File

@ -29,7 +29,7 @@ export const deviceContainerEngineBinary = `$(if [ -f /usr/bin/balena ]; then ec
export async function performLocalDeviceSSH( export async function performLocalDeviceSSH(
opts: DeviceSSHOpts, opts: DeviceSSHOpts,
): Promise<void> { ): Promise<void> {
const reduce = await import('lodash/reduce'); const { escapeRegExp, reduce } = await import('lodash');
const { spawnSshAndExitOnError } = await import('../ssh'); const { spawnSshAndExitOnError } = await import('../ssh');
const { ExpectedError } = await import('../../errors'); const { ExpectedError } = await import('../../errors');
@ -44,13 +44,12 @@ export async function performLocalDeviceSSH(
// allows the user to choose the correct container // allows the user to choose the correct container
const Docker = await import('dockerode'); const Docker = await import('dockerode');
const escapeRegex = await import('lodash/escapeRegExp');
const docker = new Docker({ const docker = new Docker({
host: opts.address, host: opts.address,
port: 2375, 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+/; const nameRegex = /\/?([a-zA-Z0-9_]+)_\d+_\d+/;
let allContainers: ContainerInfo[]; let allContainers: ContainerInfo[];
try { try {