Skip to content

Commit

Permalink
dev: Compile / ... / ... is a "valid" dir, so we check for the existe…
Browse files Browse the repository at this point in the history
…nce of the path instead
  • Loading branch information
Michael Kaleja committed Dec 13, 2023
1 parent c7040cd commit 62d15c2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { spawn, SpawnOptions } from "child_process";
import type { Plugin as VitePlugin } from "vite";
import path from "path";
import fs from "fs";

// Utility to invoke a given sbt task and fetch its output
function printSbtTask(task: string, cwd?: string): Promise<string> {
Expand Down Expand Up @@ -37,11 +37,9 @@ function printSbtTask(task: string, cwd?: string): Promise<string> {
const separator = process.platform === 'win32' ? '\r\n' : '\n';
const lines = fullOutput.trimEnd().split(separator);
const withoutLog = lines.filter(line => !line.startsWith('['));
const parsableDir = withoutLog.filter(line =>
path.parse(line).dir.length > 0
);
parsableDir.length > 0
? resolve(parsableDir.at(-1)!)
const pathExists = withoutLog.filter(line => fs.existsSync(line));
pathExists.length > 0
? resolve(pathExists.at(-1)!)
: reject(new Error(`Couldn't find a valid path in sbt output: ${fullOutput}`));
}
});
Expand Down

0 comments on commit 62d15c2

Please sign in to comment.