Skip to content

Commit 6f7043d

Browse files
committed
terminal: Added eval command
1 parent 95048d1 commit 6f7043d

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

packages/apps/terminal/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @prozilla-os/terminal
22

3+
## 1.1.1
4+
5+
### Patch Changes
6+
7+
- Added eval command
8+
39
## 1.1.0
410

511
### Minor Changes

packages/apps/terminal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@prozilla-os/terminal",
33
"description": "A terminal/shell application for ProzillaOS.",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"homepage": "https://os.prozilla.dev/terminal",
66
"author": {
77
"name": "Prozilla",

packages/apps/terminal/src/components/Terminal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
142142
if (value === "") return;
143143

144144
// Parse arguments
145-
const args = value.match(/(?:[^\s"]+|"[^"]*")+/g);
145+
let args: string[] | null = value.match(/(?:[^\s"]+|"[^"]*")+/g);
146146
if (args == null) return;
147147
if (args[0].toLowerCase() === "sudo" && args.length >= 2) args.shift();
148148

@@ -153,6 +153,13 @@ export function Terminal({ app, path: startPath, input, setTitle, close: exit, a
153153

154154
if (!command) return formatError(commandName, "Command not found");
155155

156+
args = args.map((arg) => {
157+
if (arg.startsWith("\"") && arg.endsWith("\""))
158+
return arg.slice(1, -1);
159+
160+
return arg;
161+
});
162+
156163
// Get options
157164
const options: string[] = [];
158165
const inputs: Record<string, string> = {};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Command, CommandResponse } from "../command";
2+
3+
const evalCommand = new Command()
4+
.setRequireArgs(true)
5+
.setManual({
6+
purpose: "Evaluate and execute JavaScript code",
7+
usage: "eval [input]",
8+
})
9+
.setRequireArgs(true)
10+
.setExecute(function(this: Command, args) {
11+
if (args == null || args.length == 0)
12+
return;
13+
14+
const output = eval(args[0]) as CommandResponse ?? { blank: true };
15+
return output;
16+
});
17+
18+
export { evalCommand as eval };

packages/demo/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function generateAliases() {
5454
// https://vitejs.dev/config/
5555
export default defineConfig(({ command }) => {
5656
const devMode = command == "serve";
57+
const aliases = generateAliases();
5758

5859
return {
5960
base: "/",
@@ -67,13 +68,13 @@ export default defineConfig(({ command }) => {
6768
outDir: BUILD_DIR
6869
},
6970
resolve: {
70-
alias: devMode ? generateAliases() : {},
71+
alias: devMode ? aliases : {},
7172
},
7273
server: {
7374
port: 3000,
7475
},
7576
optimizeDeps: {
76-
exclude: devMode ? ["prozilla-os"] : []
77+
exclude: devMode ? Object.keys(aliases) : []
7778
}
7879
};
7980
});

packages/prozilla-os/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# prozilla-os
22

3+
## 1.2.1
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- @prozilla-os/terminal@1.1.1
9+
310
## 1.2.0
411

512
### Minor Changes

packages/prozilla-os/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "prozilla-os",
33
"description": "a React component library written in TypeScript for building web-based operating systems, made by Prozilla.",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"homepage": "https://os.prozilla.dev",
66
"author": {
77
"name": "Prozilla",

0 commit comments

Comments
 (0)