esmate 2.1.4 → 2.2.0

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.
@@ -16,16 +16,17 @@ const task_task = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
16
16
  required: false
17
17
  }
18
18
  },
19
- async run ({ args }) {
19
+ async run ({ args, rawArgs }) {
20
20
  try {
21
21
  const task = __WEBPACK_EXTERNAL_MODULE__pkg_js_ce8daa14__.pkg.tasks[args.task];
22
+ const extraArgs = rawArgs.slice(1);
22
23
  if (!task) return void __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(`Task "${args.task}" not found in package.json`);
23
24
  const isParallel = (0, __WEBPACK_EXTERNAL_MODULE_es_toolkit_82663681__.isJSONObject)(task);
24
25
  __WEBPACK_EXTERNAL_MODULE_dotenv__["default"].config({
25
26
  quiet: true
26
27
  });
27
- if (isParallel) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execParallelly)(task);
28
- else (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execSingly)(task);
28
+ if (isParallel) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execParallelly)(task, extraArgs);
29
+ else (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execSingly)(task, extraArgs);
29
30
  } catch (error) {
30
31
  __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
31
32
  }
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { JsonValue } from "type-fest";
2
- export declare function execSingly(command: string | string[]): void;
3
- export declare function execParallelly(commands: Record<string, string | string[]>): Promise<void>;
2
+ export declare function execSingly(command: string | string[], args?: string[]): void;
3
+ export declare function execParallelly(commands: Record<string, string | string[]>, args?: string[]): Promise<void>;
4
4
  export declare function npx(command: string): void;
5
5
  export declare function readJsonSync(filePath: string): JsonValue;
package/dist/utils.js CHANGED
@@ -2,8 +2,14 @@ import * as __WEBPACK_EXTERNAL_MODULE_concurrently__ from "concurrently";
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
5
- function execSingly(command) {
6
- const cmd = Array.isArray(command) ? command.join(" && ") : command;
5
+ function mapArgs(command, args) {
6
+ args?.forEach((arg, index)=>{
7
+ command.replace(`$${index + 1}`, arg);
8
+ });
9
+ return command;
10
+ }
11
+ function execSingly(command, args) {
12
+ const cmd = Array.isArray(command) ? command.map((cmd)=>mapArgs(cmd, args)).join(" && ") : mapArgs(command, args);
7
13
  const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
8
14
  (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.spawnSync)(cmd, {
9
15
  shell: true,
@@ -11,10 +17,10 @@ function execSingly(command) {
11
17
  env
12
18
  });
13
19
  }
14
- async function execParallelly(commands) {
20
+ async function execParallelly(commands, args) {
15
21
  const concurrentCommands = [];
16
22
  for (const [name, command] of Object.entries(commands)){
17
- const cmd = Array.isArray(command) ? command.join(" && ") : command;
23
+ const cmd = Array.isArray(command) ? command.map((cmd)=>mapArgs(cmd, args)).join(" && ") : mapArgs(command, args);
18
24
  const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
19
25
  concurrentCommands.push({
20
26
  name,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "esmate",
3
3
  "type": "module",
4
- "version": "2.1.4",
4
+ "version": "2.2.0",
5
5
  "description": "Uncomplicate JavaScript",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -39,6 +39,8 @@
39
39
  "@esmate/prettier": "^1.0.6",
40
40
  "@rslib/core": "^0.7.1",
41
41
  "@types/node": "^22.19.3",
42
+ "eslint": "^9.39.2",
43
+ "prettier": "^3.7.4",
42
44
  "tsx": "^4.21.0",
43
45
  "type-fest": "^4.41.0",
44
46
  "typescript": "^5.9.3"