babel-plugin-shebang

Replace or prepend shebang

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-shebang
2111.0.04 years ago5 years agoMinified + gzip package size for babel-plugin-shebang in KB

Readme

babel-plugin-shebang
Build Status CircleCI Coverage Status License
Replace or prepend shebang>).
Useful to write #!/usr/bin/env ./node_modules/.bin/babel-node modules in development env, and compile to #!/usr/bin/env node in production env.

Installation

$ npm install babel-plugin-shebang

Example

.babelrc
{
  "plugins": ["shebang"]
}

input
#!/usr/bin/env ./node_modules/.bin/babel-node
console.log("awesome");

output
#!/usr/bin/env node
console.log("awesome");

Usage

Via .babelrc (Recommended)

.babelrc
{
  "plugins": [
    [
      "shebang",
      {
        "replacement": "#!/usr/bin/env node",
        "force": false
      }
    ]
  ]
}

Options

  • replacement (String): Defaults to #!/usr/bin/env node
  • force (Boolean): Force prepend shebang. Defaults to false

Via CLI

$ babel --plugins shebang script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["shebang"]
});

License

MIT