Node scripts dev

From handsontable/handsontable · View interactive version

Node scripts dev is an AI agent skill from the GitHub repository handsontable/handsontable. Use when creating or modifying any .mjs file in the Handsontable monorepo - scripts, utilities, or library modules. Covers .mjs conventions, native node: imports, top-level await, cross-platform compatibility, and fs/promises async patterns. Trigger on any new .mjs file creation, not just files in s

How to use this skill

Skill file

Writing Node.js `.mjs` Modules

All Node.js-side code (scripts, utilities, library modules, Playwright helpers, build tooling) is ESM .mjs.

File conventions

Adding npm scripts to the handsontable core package

handsontable/ uses a unified dispatcher. Put every command in handsontable/scripts/tasks.json and keep a thin shim in package.json:

"my-task": {
  "cmd": "node scripts/my-script.mjs",
  "deps": ["build:styles"],
  "mode": "inherit"
}
"my-task": "node scripts/run.mjs my-task"

| Field | Required | Values | Purpose |

|-------|----------|--------|---------|

| cmd | yes | shell string | Run via spawn(..., { shell: true }) |

| deps | no | task name array | Tasks that must complete first (DAG scheduler in parallel mode, sequential in direct invocation) |

| mode | no | quiet (default) \| inherit \| interactive | quiet = spinner; inherit = stream output (linters); interactive = full TTY pass-through (Jest) |

| cwd | no | path relative to handsontable/ | Working directory override |

| passthrough | no | boolean | Append extra CLI flags (after --) to the cmd |

| note | no | string | Annotation only |

Pipelines go in the pipelines block:

"pipelines": {
  "my-pipeline": {
    "before": ["clean"],
    "tasks": ["my-task", "other-task"],
    "after":  ["prepare-package-for-publish"]
  }
}

before and after run sequentially; tasks run sequentially with --sequential or via DAG with --parallel.

Wrapper packages and performance-tests/, visual-tests/ take scripts directly in their own package.json (no run.mjs dispatcher).

Imports and top-level await

Native modules over dependencies

Do not add third-party dependencies for what Node.js does natively.

| Task | Use | Not |

|------|-----|-----|

| Read/write files | node:fs/promises | fs-extra |

| Delete recursively | rm({ recursive: true, force: true }) | rimraf |

| Move/rename | rename() | mv |

| Run child process | node:child_process + promisify(exec) | execa |

| Parse CLI args | node:util parseArgs() or process.argv | yargs, commander |

| Path manipulation | node:path | slash, normalize-path |

| Glob matching | node:fs readdir + filter (glob/fast-glob only for complex patterns) | glob, fast-glob otherwise |

Cross-platform (Linux, macOS, Windows)

Existence check:

const exists = async (path) => access(path).then(() => true, () => false);

Error handling

Existing scripts

| Script | Purpose |

|--------|---------|

| scripts/sync-skills-to-cursor.mjs | Sync .claude/skills to .cursor/rules |

| scripts/translate-to-native-npm.mjs | Workspace command delegation |

| scripts/verify-bundles.mjs | Post-build version verification |

| scripts/pre-release.mjs | Pre-release version generation |

| wrappers/react-wrapper/scripts/prepare-types.mjs | Cross-platform type preparation |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.