@ast-grep/setup-lang 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/index.d.ts +1 -1
- package/index.js +8 -4
- package/index.ts +8 -4
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
package/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ declare function postinstall(config: SetupConfig): void;
|
|
|
9
9
|
/**
|
|
10
10
|
* Resolve prebuild path
|
|
11
11
|
*/
|
|
12
|
-
declare function resolvePrebuild(dir: string): string | undefined;
|
|
12
|
+
declare function resolvePrebuild(dir: string, needLog?: boolean): string | undefined;
|
|
13
13
|
export { postinstall, resolvePrebuild };
|
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ function log(...args) {
|
|
|
19
19
|
*/
|
|
20
20
|
function postinstall(config) {
|
|
21
21
|
const dir = config.dirname;
|
|
22
|
-
const prebuild = resolvePrebuild(dir);
|
|
22
|
+
const prebuild = resolvePrebuild(dir, true);
|
|
23
23
|
if (prebuild) {
|
|
24
24
|
log('prebuild found, do not need to build');
|
|
25
25
|
return;
|
|
@@ -54,14 +54,18 @@ const ARCH_MAP = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Resolve prebuild path
|
|
56
56
|
*/
|
|
57
|
-
function resolvePrebuild(dir) {
|
|
57
|
+
function resolvePrebuild(dir, needLog = false) {
|
|
58
58
|
const os = PLATFORM_MAP[process.platform];
|
|
59
59
|
const arch = ARCH_MAP[process.arch];
|
|
60
60
|
const prebuild = node_path_1.default.join(dir, 'prebuilds', `prebuild-${os}-${arch}`, 'parser.so');
|
|
61
61
|
if (!os || !arch || !node_fs_1.default.existsSync(prebuild)) {
|
|
62
|
-
|
|
62
|
+
if (needLog) {
|
|
63
|
+
log(`no prebuild for ${os} ${arch}`);
|
|
64
|
+
}
|
|
63
65
|
return undefined;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
if (needLog) {
|
|
68
|
+
log(`found prebuild for ${os} ${arch}`);
|
|
69
|
+
}
|
|
66
70
|
return prebuild;
|
|
67
71
|
}
|
package/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface SetupConfig {
|
|
|
19
19
|
*/
|
|
20
20
|
function postinstall(config: SetupConfig) {
|
|
21
21
|
const dir = config.dirname
|
|
22
|
-
const prebuild = resolvePrebuild(dir)
|
|
22
|
+
const prebuild = resolvePrebuild(dir, true)
|
|
23
23
|
if (prebuild) {
|
|
24
24
|
log('prebuild found, do not need to build')
|
|
25
25
|
return
|
|
@@ -61,7 +61,7 @@ const ARCH_MAP: Record<string, string> = {
|
|
|
61
61
|
/**
|
|
62
62
|
* Resolve prebuild path
|
|
63
63
|
*/
|
|
64
|
-
function resolvePrebuild(dir: string) {
|
|
64
|
+
function resolvePrebuild(dir: string, needLog = false) {
|
|
65
65
|
const os = PLATFORM_MAP[process.platform]
|
|
66
66
|
const arch = ARCH_MAP[process.arch]
|
|
67
67
|
const prebuild = path.join(
|
|
@@ -71,10 +71,14 @@ function resolvePrebuild(dir: string) {
|
|
|
71
71
|
'parser.so',
|
|
72
72
|
)
|
|
73
73
|
if (!os || !arch || !fs.existsSync(prebuild)) {
|
|
74
|
-
|
|
74
|
+
if (needLog) {
|
|
75
|
+
log(`no prebuild for ${os} ${arch}`)
|
|
76
|
+
}
|
|
75
77
|
return undefined
|
|
76
78
|
}
|
|
77
|
-
|
|
79
|
+
if (needLog) {
|
|
80
|
+
log(`found prebuild for ${os} ${arch}`)
|
|
81
|
+
}
|
|
78
82
|
return prebuild
|
|
79
83
|
}
|
|
80
84
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ast-grep/setup-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"typescript": "^5.7.3",
|
|
16
|
-
"@types/node": "22.
|
|
16
|
+
"@types/node": "22.19.5"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"compile-ts": "tsc"
|