Skip to content

Commit 8f6ee69

Browse files
committed
add shebang to the start of lib/index.js
1 parent b8e182b commit 8f6ee69

File tree

4 files changed

+62
-18
lines changed

4 files changed

+62
-18
lines changed

package-lock.json

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"prettier": "^3.2.5",
2020
"rollup": "^4.12.0",
2121
"rollup-plugin-auto-external": "^2.0.0",
22+
"rollup-plugin-shebang-bin": "^0.0.6",
2223
"tslib": "^2.6.2",
2324
"typescript": "^5.3.3"
2425
},

rollup.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import terser from '@rollup/plugin-terser';
2+
import shebang from 'rollup-plugin-shebang-bin';
23
import typescript from '@rollup/plugin-typescript';
34
import nodeResolve from '@rollup/plugin-node-resolve';
45
import autoExternal from 'rollup-plugin-auto-external';
56

6-
const plugins = [autoExternal(), typescript(), nodeResolve()];
7+
const plugins = [
8+
autoExternal(),
9+
typescript(),
10+
nodeResolve(),
11+
shebang({
12+
include: ['**/*.ts']
13+
})
14+
];
715

816
if (process.env.NODE_ENV === 'production') {
917
plugins.push(terser());
@@ -12,7 +20,7 @@ if (process.env.NODE_ENV === 'production') {
1220
export default {
1321
input: './src/index.ts',
1422
output: {
15-
file: './lib/index.js',
23+
dir: './lib',
1624
format: 'esm'
1725
},
1826
plugins

src/index.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ import { program } from 'commander';
22

33
import { cloneSparse, getPackageVersion } from './utils.js';
44

5-
program
6-
.version(await getPackageVersion())
7-
.description('Performs a "sparse" (i.e. partial) clone of a Git repository.')
8-
.argument('<working-copy>', 'Local Git working copy location')
9-
.argument('<repo-url>', 'Git repository clone URL')
10-
.argument('<paths...>', 'One or more paths to include in checkout')
11-
.option('-f, --force', 'Force overwriting existing working copy')
12-
.option('-g, --globs', 'Allow use of glob patterns in <paths...> argument')
13-
.action((cwd: string, repoUrl: string, paths: string[]) => {
14-
const { globs, force } = program.opts();
5+
try {
6+
await program
7+
.version(await getPackageVersion())
8+
.description(
9+
'Performs a "sparse" (i.e. partial) clone of a Git repository.'
10+
)
11+
.argument('<working-copy>', 'Local Git working copy location')
12+
.argument('<repo-url>', 'Git repository clone URL')
13+
.argument('<paths...>', 'One or more paths to include in checkout')
14+
.option('-f, --force', 'Force overwriting existing working copy')
15+
.option('-g, --globs', 'Allow use of glob patterns in <paths...> argument')
16+
.action((cwd: string, repoUrl: string, paths: string[]) => {
17+
const { globs, force } = program.opts();
1518

16-
cloneSparse(cwd, repoUrl, paths, {
17-
force,
18-
globs
19-
});
20-
})
21-
.parse();
19+
cloneSparse(cwd, repoUrl, paths, {
20+
force,
21+
globs
22+
});
23+
})
24+
.parseAsync();
25+
} catch (error) {
26+
console.error(error);
27+
}
2228

2329
export default cloneSparse;

0 commit comments

Comments
 (0)