MCPcopy Create free account
hub / github.com/fontsource/fontsource / addHashbang

Function addHashbang

packages/cli/scripts/add-hashbang.ts:8–17  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

6// Until pkgroll fixes the shebang bug, this needs to be run postbuild
7
8const addHashbang = (filepath: string) => {
9 const path = join(process.cwd(), filepath);
10 const s = new MagicString(fs.readFileSync(path, 'utf8'));
11
12 // Only add the hashbang if it's not already there
13 if (!s.toString().startsWith('#!')) {
14 s.prepend('#!/usr/bin/env node\n');
15 fs.writeFileSync(path, s.toString());
16 }
17};
18
19addHashbang('dist/cli.mjs');

Callers 1

add-hashbang.tsFile · 0.70

Calls 2

toStringMethod · 0.80
prependMethod · 0.80

Tested by

no test coverage detected