MCPcopy Create free account
hub / github.com/tiann/hapi / unpackTools

Function unpackTools

cli/src/runtime/assets.ts:88–132  ·  view source on GitHub ↗
(runtimeRoot: string)

Source from the content-addressed store, hash-verified

86}
87
88function unpackTools(runtimeRoot: string): void {
89 const platformDir = getPlatformDir();
90 const toolsDir = join(runtimeRoot, 'tools');
91 const archivesDir = join(toolsDir, 'archives');
92 const unpackedPath = join(toolsDir, 'unpacked');
93
94 if (areToolsUnpacked(unpackedPath)) {
95 return;
96 }
97
98 rmSync(unpackedPath, { recursive: true, force: true });
99 ensureDirectory(unpackedPath);
100
101 const archives = [
102 `difftastic-${platformDir}.tar.gz`,
103 `ripgrep-${platformDir}.tar.gz`
104 ];
105
106 for (const archiveName of archives) {
107 const archivePath = join(archivesDir, archiveName);
108 if (!existsSync(archivePath)) {
109 throw new Error(`Archive not found: ${archivePath}`);
110 }
111 tar.extract({
112 file: archivePath,
113 cwd: unpackedPath,
114 sync: true,
115 preserveOwner: false
116 });
117 }
118
119 if (platform() !== 'win32') {
120 const files = readdirSync(unpackedPath);
121 for (const file of files) {
122 if (file.endsWith('.node')) {
123 continue;
124 }
125 const filePath = join(unpackedPath, file);
126 const stats = statSync(filePath);
127 if (stats.isFile()) {
128 chmodSync(filePath, 0o755);
129 }
130 }
131 }
132}
133
134function runtimeAssetsReady(runtimeRoot: string): boolean {
135 return areToolsUnpacked(join(runtimeRoot, 'tools', 'unpacked')) && isTunwgReady(runtimeRoot);

Callers 1

ensureRuntimeAssetsFunction · 0.70

Calls 3

ensureDirectoryFunction · 0.85
getPlatformDirFunction · 0.70
areToolsUnpackedFunction · 0.70

Tested by

no test coverage detected