File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,38 @@ function cmakeTs() {
5
5
console . log (
6
6
"Building addon node via cmake-ts (requires cmake, ninja, and the vcpkg dependencies)" ,
7
7
)
8
- const cmakeTsPath = require . resolve ( "cmake-ts/build/main.js" )
8
+ let cmakeTsPath = tryRequireResolve ( "cmake-ts/build/main.js" )
9
+ if ( cmakeTsPath === undefined ) {
10
+ cmakeTsPath = tryRequireResolve ( "cmake-ts/build/main" )
11
+ }
12
+ if ( cmakeTsPath === undefined ) {
13
+ throw new Error (
14
+ "Failed to find cmake-ts in cmake-ts/build/main.js or cmake-ts/build/main.js" ,
15
+ )
16
+ }
9
17
10
18
cp . execFileSync ( process . execPath , [ cmakeTsPath , "nativeonly" ] , {
11
19
stdio : "inherit" ,
12
20
} )
13
21
}
14
22
23
+ /**
24
+ * Try to require resolve a path.
25
+ * @param {string } path
26
+ * @returns {string | undefined }
27
+ */
28
+ function tryRequireResolve ( path ) {
29
+ try {
30
+ return require . resolve ( path )
31
+ } catch ( error ) {
32
+ return undefined
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Log a warning if the environment is not production.
38
+ * @param {string } message
39
+ */
15
40
function devWarn ( message ) {
16
41
if ( process . env . NODE_ENV !== "production" ) {
17
42
console . warn ( message )
You can’t perform that action at this time.
0 commit comments