Skip to content

Commit

Permalink
Fix CLI hang on Linux (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Oct 29, 2024
1 parent a3a59cf commit 4d75bd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 2024-01-28 - CLI Version 0.13.2

- Fix CLI hang on Linux [#522](https://github.com/hypermodeinc/modus/pull/522)

## 2024-01-28 - CLI Version 0.13.1

- Fix issues with interactive CLI prompts [#517](https://github.com/hypermodeinc/modus/pull/517)
Expand Down
2 changes: 1 addition & 1 deletion cli/bin/modus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node --no-warnings=ExperimentalWarning
#!/usr/bin/env node
import { execute } from "@oclif/core";

await execute({ dir: import.meta.url });
31 changes: 3 additions & 28 deletions cli/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,19 @@
*/

import chalk from "chalk";
import ora, { Ora } from "ora";
import { oraPromise, Ora } from "ora";

import os from "node:os";
import path from "node:path";
import readline from "node:readline";
import { isatty } from "node:tty";
import { Readable } from "node:stream";
import { finished } from "node:stream/promises";
import { spawnSync } from "node:child_process";
import { createWriteStream } from "node:fs";
import * as fs from "./fs.js";

// Expand ~ to the user's home directory
export function expandHomeDir(filePath: string): string {
if (filePath.startsWith("~")) {
return path.normalize(path.join(os.homedir(), filePath.slice(1)));
}

return path.normalize(filePath);
}

export function isRunnable(cmd: string): boolean {
const shell = spawnSync(cmd);
if (!shell) return false;
return true;
}

export async function withSpinner<T>(text: string, fn: (spinner: Ora) => Promise<T>): Promise<T> {
const spinner = ora({
return await oraPromise(fn, {
color: "white",
text: text,
}).start();

try {
return await fn(spinner);
} finally {
spinner.stop();
}
});
}

export async function downloadFile(url: string, dest: string): Promise<boolean> {
Expand Down

0 comments on commit 4d75bd6

Please sign in to comment.