Skip to content

Commit 623ba48

Browse files
committed
fix: Shell cannot be detected in a non-login environment
1 parent fd581f0 commit 623ba48

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codifycli/plugin-core",
3-
"version": "1.1.0-beta5",
3+
"version": "1.1.0-beta7",
44
"description": "TypeScript library for building Codify plugins to manage system resources (applications, CLI tools, settings) through infrastructure-as-code",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/utils/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as fs from 'node:fs/promises';
44
import os from 'node:os';
55
import path from 'node:path';
66

7-
import { SpawnStatus, getPty } from '../pty/index.js';
7+
import { getPty, SpawnStatus } from '../pty/index.js';
88

99
export function isDebug(): boolean {
1010
return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
@@ -73,7 +73,7 @@ export const Utils = {
7373
},
7474

7575
getShell(): Shell | undefined {
76-
const shell = process.env.SHELL || '';
76+
const shell = process.env.SHELL || os.userInfo().shell || '';
7777

7878
if (shell.endsWith('bash')) {
7979
return Shell.BASH
@@ -108,7 +108,7 @@ export const Utils = {
108108
},
109109

110110
getShellRcFiles(): string[] {
111-
const shell = process.env.SHELL || '';
111+
const shell = process.env.SHELL || os.userInfo().shell || '';
112112
const homeDir = os.homedir();
113113

114114
if (shell.endsWith('bash')) {
@@ -209,9 +209,9 @@ Brew can be installed using Codify:
209209
const isAptInstalled = await $.spawnSafe('which apt');
210210
if (isAptInstalled.status === SpawnStatus.SUCCESS) {
211211
await $.spawn('apt-get update', { requiresRoot: true });
212-
const { status, data } = await $.spawnSafe(`apt-get -y install ${packageName}`, {
212+
const { status, data } = await $.spawnSafe(`apt-get -y -qq install -o Dpkg::Use-Pty=0 -o Dpkg::Progress-Fancy=0 ${packageName}`, {
213213
requiresRoot: true,
214-
env: { DEBIAN_FRONTEND: 'noninteractive', NEEDRESTART_MODE: 'a' }
214+
env: { DEBIAN_FRONTEND: 'noninteractive', NEEDRESTART_MODE: 'a', }
215215
});
216216

217217
if (status === SpawnStatus.ERROR && data.includes('E: dpkg was interrupted, you must manually run \'sudo dpkg --configure -a\' to correct the problem.')) {
@@ -265,7 +265,7 @@ Brew can be installed using Codify:
265265
if (Utils.isLinux()) {
266266
const isAptInstalled = await $.spawnSafe('which apt');
267267
if (isAptInstalled.status === SpawnStatus.SUCCESS) {
268-
const { status } = await $.spawnSafe(`apt-get autoremove -y --purge ${packageName}`, {
268+
const { status } = await $.spawnSafe(`apt-get -qq autoremove -y -o Dpkg::Use-Pty=0 -o Dpkg::Progress-Fancy=0 --purge ${packageName}`, {
269269
requiresRoot: true,
270270
env: { DEBIAN_FRONTEND: 'noninteractive', NEEDRESTART_MODE: 'a' }
271271
});

0 commit comments

Comments
 (0)