🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ast-grep/setup-lang

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ast-grep/setup-lang - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+5
-1
index.d.ts

@@ -9,2 +9,6 @@ interface SetupConfig {

declare function postinstall(config: SetupConfig): void;
export { postinstall };
/**
* Resolve prebuild path
*/
declare function resolvePrebuild(dir: string): string | undefined;
export { postinstall, resolvePrebuild };
+2
-7

@@ -7,2 +7,3 @@ "use strict";

exports.postinstall = postinstall;
exports.resolvePrebuild = resolvePrebuild;
const node_child_process_1 = require("node:child_process");

@@ -22,11 +23,5 @@ const node_fs_1 = __importDefault(require("node:fs"));

const dir = config.dirname;
const parser = node_path_1.default.join(dir, 'parser.so');
if (node_fs_1.default.existsSync(parser)) {
log('parser already exists, skipping build');
return;
}
const prebuild = resolvePrebuild(dir);
if (prebuild) {
log('copying prebuild parser');
node_fs_1.default.copyFileSync(prebuild, parser);
log('prebuild found, do not need to build');
return;

@@ -33,0 +28,0 @@ }

+14
-11

@@ -22,11 +22,5 @@ import { execSync } from 'node:child_process'

const dir = config.dirname
const parser = path.join(dir, 'parser.so')
if (fs.existsSync(parser)) {
log('parser already exists, skipping build')
return
}
const prebuild = resolvePrebuild(dir)
if (prebuild) {
log('copying prebuild parser')
fs.copyFileSync(prebuild, parser)
log('prebuild found, do not need to build')
return

@@ -37,3 +31,5 @@ }

} catch (e: unknown) {
log('build failed, please ensure tree-sitter-cli is installed as peer dependency')
log(
'build failed, please ensure tree-sitter-cli is installed as peer dependency',
)
log(e)

@@ -47,3 +43,5 @@ }

if (!fs.existsSync(existing)) {
log('tree-sitter src not found. If you are making a lang package, please run `pnpm source`.')
log(
'tree-sitter src not found. If you are making a lang package, please run `pnpm source`.',
)
return

@@ -72,3 +70,8 @@ }

const arch = ARCH_MAP[process.arch]
const prebuild = path.join(dir, 'prebuilds', `prebuild-${os}-${arch}`, 'parser.so')
const prebuild = path.join(
dir,
'prebuilds',
`prebuild-${os}-${arch}`,
'parser.so',
)
if (!os || !arch || !fs.existsSync(prebuild)) {

@@ -82,2 +85,2 @@ log(`no prebuild for ${os} ${arch}`)

export { postinstall }
export { postinstall, resolvePrebuild }
{
"name": "@ast-grep/setup-lang",
"version": "0.0.3",
"version": "0.0.4",
"private": false,

@@ -16,3 +16,3 @@ "description": "",

"typescript": "^5.7.3",
"@types/node": "22.13.4"
"@types/node": "22.17.1"
},

@@ -19,0 +19,0 @@ "scripts": {