From 3c546aa1991090f38f9562a7df4cc54e7af61db0 Mon Sep 17 00:00:00 2001 From: Felipe Lalanne <1822826+pipex@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:14:37 -0300 Subject: [PATCH] Add sync directory to lint sources --- sync/device.ts | 7 +++---- sync/init.ts | 4 ++-- sync/livepush.ts | 13 +++++++------ sync/logs.ts | 7 +++---- sync/sync.ts | 2 +- tsconfig.json | 1 + 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sync/device.ts b/sync/device.ts index 57216196..3f1f6dee 100644 --- a/sync/device.ts +++ b/sync/device.ts @@ -1,11 +1,10 @@ -import * as Docker from 'dockerode'; -import { Dockerfile } from 'livepush'; -import * as _ from 'lodash'; +import Docker from 'dockerode'; +import type { Dockerfile } from 'livepush'; import { Builder } from 'resin-docker-build'; import { promises as fs } from 'fs'; import * as Path from 'path'; -import { Readable } from 'stream'; +import type { Readable } from 'stream'; import * as tar from 'tar-stream'; import * as readline from 'readline'; diff --git a/sync/init.ts b/sync/init.ts index ec67b9a7..eb44780a 100644 --- a/sync/init.ts +++ b/sync/init.ts @@ -1,5 +1,5 @@ -import * as Docker from 'dockerode'; -import { Dockerfile } from 'livepush'; +import type Docker from 'dockerode'; +import type { Dockerfile } from 'livepush'; import * as device from './device'; import { setTimeout } from 'timers/promises'; diff --git a/sync/livepush.ts b/sync/livepush.ts index 1edad0f6..6b7f6c0f 100644 --- a/sync/livepush.ts +++ b/sync/livepush.ts @@ -1,9 +1,10 @@ import * as chokidar from 'chokidar'; -import * as Docker from 'dockerode'; -import * as _ from 'lodash'; -import * as Path from 'path'; +import type Docker from 'dockerode'; +import _ from 'lodash'; +import Path from 'path'; -import { Dockerfile, Livepush } from 'livepush'; +import type { Dockerfile } from 'livepush'; +import { Livepush } from 'livepush'; // TODO: Pass build args to the livepush process export async function startLivepush(opts: { @@ -37,7 +38,7 @@ export async function startLivepush(opts: { const livepushExecutor = getExecutor(livepush); const watcher = chokidar .watch('.', { - ignored: /((^|[\/\\])\..|(node_modules|sync|test)\/.*)/, + ignored: /((^|[/\\])\..|(node_modules|sync|test)\/.*)/, ignoreInitial: opts.noinit, }) .on('add', (path) => livepushExecutor(path)) @@ -65,6 +66,6 @@ const getExecutor = (livepush: Livepush) => { if (deleted) { deletedFiles.push(deleted); } - actualExecutor(); + return actualExecutor(); }; }; diff --git a/sync/logs.ts b/sync/logs.ts index 33f3d0fd..fddd6cae 100644 --- a/sync/logs.ts +++ b/sync/logs.ts @@ -1,5 +1,4 @@ -import * as Docker from 'dockerode'; -import * as _ from 'lodash'; +import type Docker from 'dockerode'; export async function setupLogs( docker: Docker, @@ -16,7 +15,7 @@ export async function setupLogs( since: lastReadTimestamp, }); - stream.on('data', chunk => { + stream.on('data', (chunk) => { const { message, timestamp } = extractMessage(chunk); // Add one here, other we can end up constantly reading // the same log line @@ -26,7 +25,7 @@ export async function setupLogs( // This happens when a container is restarted stream.on('end', () => { - setupLogs(docker, containerId, lastReadTimestamp); + void setupLogs(docker, containerId, lastReadTimestamp); }); } diff --git a/sync/sync.ts b/sync/sync.ts index e63190a8..077aa375 100644 --- a/sync/sync.ts +++ b/sync/sync.ts @@ -55,7 +55,7 @@ const argv = yargs .scriptName('npm run sync --') .alias('h', 'help').argv; -(async () => { +void (async () => { const address = argv['device-address']!; const dockerfile = new livepush.Dockerfile( await fs.readFile('Dockerfile.template'), diff --git a/tsconfig.json b/tsconfig.json index dd9a8336..3ccf2ef8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,6 +32,7 @@ "src/**/*", "test/**/*", "typings/**/*.d.ts", + "sync/**/*", "build-utils/**/*" ] }