From e7a53eb1831c76fcaa7e3eb0c9560746ef133ecc Mon Sep 17 00:00:00 2001
From: anthony
Date: Sat, 2 Aug 2025 22:22:35 -0700
Subject: [PATCH] add a raw js example
---
README.md | 1 -
examples/multifile/lib.mts | 2 +-
examples/raw_js/default.nix | 6 ++++++
examples/raw_js/js_entrypoint.js | 5 +++++
examples/raw_js/js_entrypoint.mjs | 5 +++++
flake.nix | 3 ++-
6 files changed, 19 insertions(+), 3 deletions(-)
create mode 100644 examples/raw_js/default.nix
create mode 100644 examples/raw_js/js_entrypoint.js
create mode 100644 examples/raw_js/js_entrypoint.mjs
diff --git a/README.md b/README.md
index b2c4c1e..8029266 100644
--- a/README.md
+++ b/README.md
@@ -71,4 +71,3 @@ to get ide support, run `npm i google/zx` in the root of your project. Unfortuna
## out of scope
- `nixzx` does not allow you to add other npm packages (prs welcome).
-- non-`mts` extensions.
diff --git a/examples/multifile/lib.mts b/examples/multifile/lib.mts
index 0f1c7a8..a7092a8 100644
--- a/examples/multifile/lib.mts
+++ b/examples/multifile/lib.mts
@@ -1,6 +1,6 @@
import { $ } from "zx";
-export const callHello = async () => {
+export const callHello = async (): Promise => {
const proc = await $`hello`;
return `hello output: ${proc.stdout}`;
};
diff --git a/examples/raw_js/default.nix b/examples/raw_js/default.nix
new file mode 100644
index 0000000..5bc4e5e
--- /dev/null
+++ b/examples/raw_js/default.nix
@@ -0,0 +1,6 @@
+pkgs:
+pkgs.writeZxApplication {
+ name = "raw_js";
+ runtimeInputs = with pkgs; [hello];
+ src = ./js_entrypoint.js;
+}
diff --git a/examples/raw_js/js_entrypoint.js b/examples/raw_js/js_entrypoint.js
new file mode 100644
index 0000000..f970b34
--- /dev/null
+++ b/examples/raw_js/js_entrypoint.js
@@ -0,0 +1,5 @@
+import { $ } from "zx";
+
+const proc = await $`hello`;
+console.log(`hello proc from js: ${proc.stdout}`);
+
diff --git a/examples/raw_js/js_entrypoint.mjs b/examples/raw_js/js_entrypoint.mjs
new file mode 100644
index 0000000..f970b34
--- /dev/null
+++ b/examples/raw_js/js_entrypoint.mjs
@@ -0,0 +1,5 @@
+import { $ } from "zx";
+
+const proc = await $`hello`;
+console.log(`hello proc from js: ${proc.stdout}`);
+
diff --git a/flake.nix b/flake.nix
index e1554df..b2b9fab 100644
--- a/flake.nix
+++ b/flake.nix
@@ -36,8 +36,9 @@
touch $out
'';
in {
- # simple = checkExit0 "simple";
+ simple = checkExit0 "simple";
multifile = checkExit0 "multifile";
+ raw_js = checkExit0 "raw_js";
};
devShells = let