builderman 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,12 +2,6 @@ export interface TaskConfig {
2
2
  name: string;
3
3
  command: string;
4
4
  cwd: string;
5
- }
6
- export interface PipelineTaskConfig {
7
- name: string;
8
- path?: string;
9
- cwd?: string;
10
- command: string;
11
5
  requiresEvents?: string[];
12
6
  }
13
7
  export interface Task extends TaskConfig {
@@ -28,4 +22,4 @@ export declare function task(config: TaskConfig): Task;
28
22
  /**
29
23
  * Creates a pipeline that manages task execution with event-based dependencies.
30
24
  */
31
- export declare function pipeline(configs: (Task | PipelineTaskConfig)[]): Pipeline;
25
+ export declare function pipeline(tasks: Task[]): Pipeline;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { EventEmitter } from "node:events";
3
+ import * as path from "node:path";
3
4
  const EVENT_PREFIX = "__BUILDERMAN_EVENT__:";
4
5
  /**
5
6
  * Emits an event that can be received by the parent process.
@@ -17,29 +18,13 @@ export function task(config) {
17
18
  name: config.name,
18
19
  command: config.command,
19
20
  cwd: config.cwd,
20
- requiresEvents: [],
21
+ requiresEvents: config.requiresEvents || [],
21
22
  };
22
23
  }
23
24
  /**
24
25
  * Creates a pipeline that manages task execution with event-based dependencies.
25
26
  */
26
- export function pipeline(configs) {
27
- const tasks = configs.map((config) => {
28
- if ("requiresEvents" in config || "path" in config) {
29
- // It's a PipelineTaskConfig
30
- const taskConfig = config;
31
- return {
32
- name: taskConfig.name,
33
- command: taskConfig.command,
34
- cwd: taskConfig.path || taskConfig.cwd || process.cwd(),
35
- requiresEvents: taskConfig.requiresEvents || [],
36
- };
37
- }
38
- else {
39
- // It's already a Task
40
- return config;
41
- }
42
- });
27
+ export function pipeline(tasks) {
43
28
  return {
44
29
  async run() {
45
30
  const eventEmitter = new EventEmitter();
@@ -63,11 +48,38 @@ export function pipeline(configs) {
63
48
  if (runningTasks.has(task.name)) {
64
49
  return;
65
50
  }
66
- const [command, ...args] = task.command.split(/\s+/);
67
- const child = spawn(command, args, {
51
+ // Ensure node_modules/.bin is in PATH for local dependencies
52
+ // Resolve cwd relative to current working directory
53
+ const taskCwd = path.isAbsolute(task.cwd)
54
+ ? task.cwd
55
+ : path.resolve(process.cwd(), task.cwd);
56
+ const localBinPath = path.join(taskCwd, "node_modules", ".bin");
57
+ // Build PATH with local node_modules/.bin first (as absolute path), then existing PATH
58
+ const existingPath = process.env.PATH || process.env.Path || "";
59
+ const pathSeparator = process.platform === "win32" ? ";" : ":";
60
+ // Collect all potential bin paths (local first, then root, then existing)
61
+ const binPaths = [localBinPath];
62
+ // Also add root node_modules/.bin if different from local
63
+ const rootBinPath = path.join(process.cwd(), "node_modules", ".bin");
64
+ if (rootBinPath !== localBinPath) {
65
+ binPaths.push(rootBinPath);
66
+ }
67
+ // Add existing PATH
68
+ if (existingPath) {
69
+ binPaths.push(existingPath);
70
+ }
71
+ const newPath = binPaths.join(pathSeparator);
72
+ const env = {
73
+ ...process.env,
74
+ PATH: newPath,
75
+ Path: newPath, // Windows uses both PATH and Path
76
+ };
77
+ // Use shell mode to allow commands like "vite dev" to work properly
78
+ const child = spawn(task.command, {
68
79
  cwd: task.cwd,
69
80
  stdio: ["inherit", "pipe", "pipe"],
70
- shell: process.platform === "win32",
81
+ shell: true,
82
+ env,
71
83
  });
72
84
  runningTasks.set(task.name, child);
73
85
  // Parse events from stdout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "builderman",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "An awesome new package",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",