nadle
Version:
A modern, type-safe task runner for Node.js inspired by the awesome Gradle build tool
78 lines (75 loc) • 2.28 kB
JavaScript
import {
configure,
tasks
} from "./chunk-JXJCDWE4.js";
import {
DefaultReporter,
Logger,
Nadle,
SupportLogLevels,
TaskRegistry,
TaskStatus,
formatSuggestions,
normalizeGlobPath,
resolveTask,
taskRegistry
} from "./chunk-U7OSCGJU.js";
// src/tasks/pnpm-task.ts
import { execa } from "execa";
var PnpmTask = {
run: async ({ options, context }) => {
const { args } = options;
context.nadle.logger.info(`Running pnpm command: pnpm ${args.join(" ")}`);
const subprocess = execa("pnpm", args, { all: true, cwd: context.workingDir, env: { FORCE_COLOR: "1" } });
subprocess.all?.on("data", (chunk) => {
context.nadle.logger.log(chunk.toString());
});
await subprocess;
context.nadle.logger.info(`pnpm command completed successfully.`);
}
};
// src/tasks/exec-task.ts
import { execa as execa2, parseCommandString } from "execa";
var ExecTask = {
run: async ({ options, context }) => {
const { args, command } = options;
const commandArguments = typeof args === "string" ? parseCommandString(args) : args;
context.nadle.logger.info(`Running command: ${command} ${commandArguments.join(" ")}`);
const subprocess = execa2(command, commandArguments, { all: true, cwd: context.workingDir, env: { FORCE_COLOR: "1" } });
subprocess.all?.on("data", (chunk) => {
context.nadle.logger.log(chunk.toString());
});
await subprocess;
context.nadle.logger.info(`Run completed successfully.`);
}
};
// src/tasks/delete-task.ts
import { glob } from "glob";
import { rimraf } from "rimraf";
var DeleteTask = {
run: async ({ options, context }) => {
const { paths, ...restOptions } = options;
const { workingDir } = context;
const matchPaths = await glob(paths, { cwd: workingDir });
context.nadle.logger.info(`Current working dir: ${workingDir}`);
context.nadle.logger.info("Deleting paths:", matchPaths.map(normalizeGlobPath).join(", "));
await rimraf(paths, { ...restOptions, glob: { cwd: workingDir, ...restOptions } });
}
};
export {
DefaultReporter,
DeleteTask,
ExecTask,
Logger,
Nadle,
PnpmTask,
SupportLogLevels,
TaskRegistry,
TaskStatus,
configure,
formatSuggestions,
resolveTask,
taskRegistry,
tasks
};
//# sourceMappingURL=index.js.map