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() {
55 console . log (
66 "Building addon node via cmake-ts (requires cmake, ninja, and the vcpkg dependencies)" ,
77 )
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+ }
917
1018 cp . execFileSync ( process . execPath , [ cmakeTsPath , "nativeonly" ] , {
1119 stdio : "inherit" ,
1220 } )
1321}
1422
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+ */
1540function devWarn ( message ) {
1641 if ( process . env . NODE_ENV !== "production" ) {
1742 console . warn ( message )
You can’t perform that action at this time.
0 commit comments