mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 09:26:42 +00:00
Merge pull request #1668 from balena-io/native-check
Switch to native type checks
This commit is contained in:
commit
f30e486562
@ -18,7 +18,6 @@
|
||||
import { OptionDefinition } from 'capitano';
|
||||
import * as ent from 'ent';
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import * as readline from 'readline';
|
||||
|
||||
export function getOptionPrefix(signature: string) {
|
||||
@ -36,11 +35,11 @@ export function getOptionSignature(signature: string) {
|
||||
export function parseCapitanoOption(option: OptionDefinition): string {
|
||||
let result = getOptionSignature(option.signature);
|
||||
|
||||
if (_.isArray(option.alias)) {
|
||||
if (Array.isArray(option.alias)) {
|
||||
for (const alias of option.alias) {
|
||||
result += `, ${getOptionSignature(alias)}`;
|
||||
}
|
||||
} else if (_.isString(option.alias)) {
|
||||
} else if (typeof option.alias === 'string') {
|
||||
result += `, ${getOptionSignature(option.alias)}`;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,6 @@ export const logs: CommandDefinition<
|
||||
async action(params, options, done) {
|
||||
normalizeUuidProp(params);
|
||||
const balena = getBalenaSdk();
|
||||
const isArray = await import('lodash/isArray');
|
||||
const { serviceIdToName } = await import('../utils/cloud');
|
||||
const { displayDeviceLogs, displayLogObject } = await import(
|
||||
'../utils/device/logs'
|
||||
@ -101,7 +100,7 @@ export const logs: CommandDefinition<
|
||||
|
||||
const servicesToDisplay =
|
||||
options.service != null
|
||||
? isArray(options.service)
|
||||
? Array.isArray(options.service)
|
||||
? options.service
|
||||
: [options.service]
|
||||
: undefined;
|
||||
|
@ -249,7 +249,7 @@ module.exports =
|
||||
options.pinDevice = options['pin-device-to-release'] || false
|
||||
delete options['pin-device-to-release']
|
||||
|
||||
if _.isArray(options['add-certificate'])
|
||||
if Array.isArray(options['add-certificate'])
|
||||
certificates = options['add-certificate']
|
||||
else if options['add-certificate'] == undefined
|
||||
certificates = []
|
||||
|
@ -263,7 +263,6 @@ export const push: CommandDefinition<
|
||||
async action(params, options) {
|
||||
const sdk = getBalenaSdk();
|
||||
const Bluebird = await import('bluebird');
|
||||
const isArray = await import('lodash/isArray');
|
||||
const remote = await import('../utils/remote-build');
|
||||
const deviceDeploy = await import('../utils/device/deploy');
|
||||
const { checkLoggedIn } = await import('../utils/patterns');
|
||||
@ -348,7 +347,7 @@ export const push: CommandDefinition<
|
||||
const device = appOrDevice;
|
||||
const servicesToDisplay =
|
||||
options.service != null
|
||||
? isArray(options.service)
|
||||
? Array.isArray(options.service)
|
||||
? options.service
|
||||
: [options.service]
|
||||
: undefined;
|
||||
|
@ -18,7 +18,6 @@ import { CommandDefinition } from 'capitano';
|
||||
import { stripIndent } from 'common-tags';
|
||||
import * as _ from 'lodash';
|
||||
import { createServer, Server, Socket } from 'net';
|
||||
import { isArray } from 'util';
|
||||
|
||||
import { getBalenaSdk } from '../utils/lazy';
|
||||
import { getOnlineTargetUuid } from '../utils/patterns';
|
||||
@ -121,7 +120,7 @@ export const tunnel: CommandDefinition<Args, Options> = {
|
||||
}
|
||||
|
||||
const ports =
|
||||
typeof options.port !== 'string' && isArray(options.port)
|
||||
typeof options.port !== 'string' && Array.isArray(options.port)
|
||||
? (options.port as string[])
|
||||
: [options.port as string];
|
||||
|
||||
|
@ -376,9 +376,7 @@ getPreviousRepos = (sdk, docker, logger, appID) ->
|
||||
logger.logDebug("Failed to access previously pushed image repo: #{e}")
|
||||
|
||||
authorizePush = (sdk, logger, tokenAuthEndpoint, registry, images, previousRepos) ->
|
||||
_ = require('lodash')
|
||||
|
||||
if not _.isArray(images)
|
||||
if not Array.isArray(images)
|
||||
images = [ images ]
|
||||
|
||||
images.push previousRepos...
|
||||
|
@ -250,7 +250,7 @@ export class DeviceAPI {
|
||||
// the `as string` shouldn't be necessary, but the type system
|
||||
// is getting a little confused
|
||||
url = (opts as ObjectWithUrl).url as string;
|
||||
} else if (_.isString(opts)) {
|
||||
} else if (typeof opts === 'string') {
|
||||
url = opts;
|
||||
}
|
||||
|
||||
|
@ -148,8 +148,7 @@ generateConnectOpts = (opts) ->
|
||||
return connectOpts
|
||||
|
||||
parseBuildArgs = (args) ->
|
||||
_ = require('lodash')
|
||||
if not _.isArray(args)
|
||||
if not Array.isArray(args)
|
||||
args = [ args ]
|
||||
buildArgs = {}
|
||||
args.forEach (arg) ->
|
||||
|
@ -21,7 +21,7 @@ export function normalizeUuidProp(
|
||||
params: { [key: string]: any },
|
||||
propName = 'uuid',
|
||||
) {
|
||||
if (_.isNumber(params[propName])) {
|
||||
if (typeof params[propName] === 'number') {
|
||||
params[propName] =
|
||||
params[propName + '_raw'] || _.toString(params[propName]);
|
||||
}
|
||||
@ -33,7 +33,7 @@ export async function disambiguateReleaseParam(
|
||||
paramRaw: string | undefined,
|
||||
) {
|
||||
// the user has passed an argument that was parsed as a string
|
||||
if (!_.isNumber(param)) {
|
||||
if (typeof param !== 'number') {
|
||||
return param;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user