diff --git a/packages/protolib/bundles/os/context2/index.ts b/packages/protolib/bundles/os/context2/index.ts
index 4151b0e55..8a20cd1f9 100644
--- a/packages/protolib/bundles/os/context2/index.ts
+++ b/packages/protolib/bundles/os/context2/index.ts
@@ -1,8 +1,10 @@
import {readFile} from './readFile'
import {writeFile} from './writeFile'
import { runCommand } from './RunCommand'
+import {listDir} from './listDir'
export default {
readFile,
writeFile,
+ listDir,
runCommand
}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/context2/listDir.ts b/packages/protolib/bundles/os/context2/listDir.ts
new file mode 100644
index 000000000..1d8f3b084
--- /dev/null
+++ b/packages/protolib/bundles/os/context2/listDir.ts
@@ -0,0 +1,24 @@
+import fs from 'fs/promises'
+import {join} from 'path'
+
+export const listDir = async(options:{
+ path: string,
+ done?: (list) => {},
+ error?: (err) => {}
+}) => {
+ const path = options.path
+ const done = options.done || (() => {})
+ const error = options.error
+
+ try {
+ const list = await fs.readdir(join('../../', path))
+ done(list)
+ return list
+ } catch(err) {
+ if(error) {
+ error(err)
+ } else {
+ throw err
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/masks2/ListDir.tsx b/packages/protolib/bundles/os/masks2/ListDir.tsx
new file mode 100644
index 000000000..3d01b9370
--- /dev/null
+++ b/packages/protolib/bundles/os/masks2/ListDir.tsx
@@ -0,0 +1,46 @@
+import { Node, NodeOutput, NodeParams, filterObject, restoreObject } from 'protoflow';
+import { useColorFromPalette } from 'protoflow/src/diagram/Theme'
+import { Folder } from 'lucide-react'
+
+const ListDir = ({ node = {}, nodeData = {}, children }: any) => {
+ const color = useColorFromPalette(12)
+ return (
+
+
+
+
+
+
+ )
+}
+
+export default {
+ id: 'os2.listDir',
+ type: 'CallExpression',
+ category: "OS",
+ keywords: ['fs', 'os', 'read', 'directory', 'list'],
+ check: (node, nodeData) => {
+ return node.type == "CallExpression" && nodeData.to?.startsWith('context.os2.listDir')
+ },
+ getComponent: (node, nodeData, children) => ,
+ filterChildren: filterObject({keys: {
+ path: 'input',
+ done: 'output',
+ error: 'output'
+ }}),
+ restoreChildren: restoreObject({keys: {
+ path: 'input',
+ done: { params: {'param-done': { key: "list"}}},
+ error: { params: { 'param-error': { key: "err"}}}
+ }}),
+ getInitialData: () => {
+ return {
+ await: true,
+ to: 'context.os2.listDir',
+ "mask-path": {
+ value: "",
+ kind: "StringLiteral"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/protolib/bundles/os/masks2/index.tsx b/packages/protolib/bundles/os/masks2/index.tsx
index ea0edcc19..57ec3794c 100644
--- a/packages/protolib/bundles/os/masks2/index.tsx
+++ b/packages/protolib/bundles/os/masks2/index.tsx
@@ -1,8 +1,10 @@
import ReadFile from "./ReadFile";
import WriteFile from './WriteFile';
import RunCommand from "./RunCommand";
+import ListDir from "./ListDir";
export default [
ReadFile,
WriteFile,
+ ListDir,
RunCommand
]
\ No newline at end of file