Registry / devops / shelljs-transpiler

shelljs-transpiler

JSON →
library0.2.6jsnpmunverified

Translate Bash scripts to ShellJS (shelljs) code. Current stable version is 0.2.6, with a pre-1.0 release cadence. It supports both a web interface and a CLI tool `sh2js`. Unlike manual porting, it automates conversion of common Bash constructs to ShellJS API calls. Notable limitations: not all Bash syntax is handled until v1.0; translations may rely on unimplemented ShellJS features. The tool is experimental and community-driven, with limited maintenance.

npm install shelljs-transpiler
INSTALL
IMPORT
SIG · SHELLJS-TRANSPILER
S
shelljs-transpiler
devopsjavascriptv0.2.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sh2js
npx sh2js script.sh output.js
npm run sh2js script.sh output.js
CLI tool; no import, use npx or global install.
transpile
import { transpile } from 'shelljs-transpiler'
const { transpile } = require('shelljs-transpiler')
ESM-only; CJS require may fail or give different result.
default export
import shelljsTranspiler from 'shelljs-transpiler'
const shelljsTranspiler = require('shelljs-transpiler')
Default export is a function that transpiles source code.
ShellJS
import { ShellJS } from 'shelljs-transpiler'
Type import if using TypeScript; not a runtime export.

Transpile a simple Bash script (echo and ls) to ShellJS code.

import { transpile } from 'shelljs-transpiler'; const bashScript = 'echo hello; ls -la'; const shelljsCode = transpile(bashScript); console.log(shelljsCode); // Output: 'console.log("hello");\nshell.ls("-la");'
sh2js --version
Debug
Known issues
breakingSome Bash syntax may not be handled until v1.0.
fix
File an issue on GitHub with your failing script.
affects: <1.0.0
gotchaTranslated scripts may depend on ShellJS features not yet implemented.
fix
Check the output and manually adjust to use existing ShellJS API.
affects: all
deprecatedThe CLI tool `sh2js` is experimental and may change.
fix
Use npx to run the latest version or install globally.
affects: all
gotchaPlugin system via `--plugins` is experimental and may not work as expected.
fix
Avoid using plugins until stable.
affects: all
breakingRequires Node.js >= 8 for ES6 features.
fix
Upgrade Node.js or use a transpiler like Babel.
affects: >=0.2.0
Errors
Common errors & fixes
SyntaxError: Unexpected token
Input Bash script contains unsupported syntax.
fix
Simplify the script or report the issue.
TypeError: transpile is not a function
Incorrect import: using CJS require instead of ESM import.
fix
Use `import { transpile } from 'shelljs-transpiler'`.
sh2js: command not found
ShellJS-transpiler not installed globally or not in PATH.
fix
Install globally: `npm install -g shelljs-transpiler` or use `npx sh2js`.
Error: Plugin not found
Specified plugin name is misspelled or not installed.
fix
Check plugin name and ensure it is installed as a npm package.
Upgrade
Version history
0.2.6latest on npm
Audit
Dependencies
shelljsrequiredRuntime dependency for the generated output to execute.
Agent activity
2 hits · last 30 days
node
2
Resources
shelljs-transpiler — npm install shelljs-transpiler · libregistry