Skip to content

Commit dc12a2f

Browse files
authored
Added executable script plugin code (#2)
1 parent e5f8e3d commit dc12a2f

File tree

7 files changed

+826
-0
lines changed

7 files changed

+826
-0
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.16.1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# rollup-plugin-executable-script
2+
23
A plugin to tell system to use node interpreter and provide executable permissions to the output file.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import fs from "fs";
2+
3+
const executableScript = async () => {
4+
let executableScriptPath = "";
5+
6+
return {
7+
name: "executableScript",
8+
renderChunk: (code) => `#!/usr/bin/env node\n${code}`,
9+
generateBundle({ file }) {
10+
executableScriptPath = file;
11+
},
12+
writeBundle() {
13+
fs.chmodSync(executableScriptPath, 0o755);
14+
},
15+
};
16+
};
17+
18+
export default executableScript;

package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "rollup-plugin-executable-script",
3+
"version": "1.0.0",
4+
"description": "A plugin to tell system to use node interpreter and provide executable permissions to the output file.",
5+
"license": "MIT",
6+
"author": "Thejus Paul",
7+
"homepage": "https://github.com/Thejus-Paul/rollup-plugin-executable-script",
8+
"bugs": "https://github.com/Thejus-Paul/rollup-plugin-executable-script/issues",
9+
"main": "./dist/index.cjs.js",
10+
"module": "./dist/index.js",
11+
"type": "module",
12+
"types": "./types/index.d.ts",
13+
"exports": {
14+
"default": "./dist/index.cjs.js",
15+
"import": "./dist/index.js",
16+
"types": "./types/index.d.ts"
17+
},
18+
"engines": {
19+
"node": ">=16.0.0"
20+
},
21+
"scripts": {
22+
"build": "rollup -c"
23+
},
24+
"files": [
25+
"dist",
26+
"types",
27+
"README.md",
28+
"LICENSE"
29+
],
30+
"keywords": [
31+
"rollup-plugin",
32+
"executable",
33+
"script"
34+
],
35+
"peerDependencies": {
36+
"rollup": "^2.78.0||^3.0.0"
37+
},
38+
"peerDependenciesMeta": {
39+
"rollup": {
40+
"optional": true
41+
}
42+
},
43+
"devDependencies": {
44+
"@rollup/plugin-babel": "6.0.3",
45+
"@rollup/plugin-commonjs": "25.0.2",
46+
"@rollup/plugin-json": "6.0.0",
47+
"@rollup/plugin-node-resolve": "15.1.0",
48+
"rollup": "3.25.3",
49+
"rollup-plugin-analyzer": "4.0.0",
50+
"rollup-plugin-cleaner": "1.0.0"
51+
}
52+
}

0 commit comments

Comments
 (0)