Skip to content

Commit f9d3888

Browse files
authored
Merge pull request #105 from thefrontside/tm/fix-shellwords
Do not use named imports with shellwords
2 parents f4dcd28 + 5c2db44 commit f9d3888

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

fx/request.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ import { beforeEach, describe, it } from "@effectionx/bdd";
22
import { expect } from "@std/expect";
33

44
import { call, ensure, withResolvers } from "effection";
5-
import { createServer } from "node:http";
5+
import {
6+
createServer,
7+
type IncomingMessage,
8+
type ServerResponse,
9+
} from "node:http";
610
import { json, request } from "./request.ts";
711

812
// Ensure to run tests with --allow-net permission
913
describe("request() and json()", () => {
1014
let url: string;
1115
beforeEach(function* () {
12-
let server = createServer((_req, res) => {
13-
res.writeHead(200, { "Content-Type": "application/json" });
14-
res.end(JSON.stringify({ id: 1, title: "do things" }));
15-
});
16+
let server = createServer(
17+
(_req: IncomingMessage, res: ServerResponse) => {
18+
res.writeHead(200, { "Content-Type": "application/json" });
19+
res.end(JSON.stringify({ id: 1, title: "do things" }));
20+
},
21+
);
1622

1723
const ready = withResolvers<void>();
1824
server.listen(0, () => ready.resolve());

process/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effectionx/process",
33
"exports": "./mod.ts",
4-
"version": "0.6.1",
4+
"version": "0.6.2",
55
"license": "MIT",
66
"imports": {
77
"@types/cross-spawn": "npm:@types/cross-spawn@6.0.6",

process/src/exec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { split } from "shellwords";
1+
import * as shellwords from "shellwords";
22

33
import { type Operation, spawn } from "effection";
44
import type {
@@ -34,7 +34,7 @@ const createProcess: CreateOSProcess = (cmd, opts) => {
3434
* forever, consider using `daemon()`
3535
*/
3636
export function exec(command: string, options: ExecOptions = {}): Exec {
37-
let [cmd, ...args] = options.shell ? [command] : split(command);
37+
let [cmd, ...args] = options.shell ? [command] : shellwords.split(command);
3838
let opts = { ...options, arguments: args.concat(options.arguments || []) };
3939

4040
return {

watch/watch.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import { exec, type ExecOptions, type Process } from "@effectionx/process";
2222

2323
import { debounce } from "./stream-helpers.ts";
2424

25+
// Extended FSWatcher interface that includes EventEmitter methods
26+
interface FSWatcherWithEvents {
27+
on(event: string, listener: (...args: EmitArgsWithName) => void): this;
28+
close(): Promise<void>;
29+
}
30+
2531
/**
2632
* Represents a single start of the specified command
2733
*/
@@ -105,14 +111,16 @@ export function watch(options: WatchOptions): Stream<Start, never> {
105111

106112
let gitignored = yield* findIgnores(options.path);
107113

114+
// Cast to extended interface that includes EventEmitter methods
108115
let watcher = chokidar.watch(options.path, {
109116
ignored: (path) => {
110117
let relpath = relative(options.path, path);
111118
let isGit = relpath === ".git" || relpath.startsWith(".git");
112119
return isGit || gitignored(path);
113120
},
114121
ignoreInitial: true,
115-
});
122+
}) as unknown as FSWatcherWithEvents;
123+
116124
let { event = "all" } = options;
117125
watcher.on(event, (...args: EmitArgsWithName) => {
118126
if (event !== "all") {

0 commit comments

Comments
 (0)