Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI hang on Linux #521

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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