File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717const fs = require ( 'fs' ) ;
1818const path = require ( 'path' ) ;
1919const debug = require ( 'debug' ) ( 'rclnodejs' ) ;
20+ const { detectUbuntuCodename } = require ( './utils' ) ;
2021
2122let nativeModule = null ;
2223
23- /**
24- * Detect Ubuntu codename from /etc/os-release
25- * @returns {string|null } Ubuntu codename (e.g., 'noble', 'jammy') or null
26- */
27- function detectUbuntuCodename ( ) {
28- if ( process . platform !== 'linux' ) {
29- return null ;
30- }
31-
32- try {
33- const osRelease = fs . readFileSync ( '/etc/os-release' , 'utf8' ) ;
34- const match = osRelease . match ( / ^ V E R S I O N _ C O D E N A M E = ( .* ) $ / m) ;
35- return match ? match [ 1 ] . trim ( ) : null ;
36- } catch {
37- return null ;
38- }
39- }
40-
4124// Simplified loader: only use prebuilt binaries with exact Ubuntu/ROS2/arch match
4225// Note: Prebuilt binaries are only supported on Linux (Ubuntu) platform
4326function customFallbackLoader ( ) {
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2025, The Robot Web Tools Contributors
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ const fs = require ( 'fs' ) ;
16+
17+ /**
18+ * Detect Ubuntu codename from /etc/os-release
19+ * @returns {string|null } Ubuntu codename (e.g., 'noble', 'jammy') or null if not detectable
20+ */
21+ function detectUbuntuCodename ( ) {
22+ if ( process . platform !== 'linux' ) {
23+ return null ;
24+ }
25+
26+ try {
27+ const osRelease = fs . readFileSync ( '/etc/os-release' , 'utf8' ) ;
28+ const match = osRelease . match ( / ^ V E R S I O N _ C O D E N A M E = ( .* ) $ / m) ;
29+ return match ? match [ 1 ] . trim ( ) : null ;
30+ } catch ( e ) {
31+ return null ;
32+ }
33+ }
34+
35+ module . exports = {
36+ detectUbuntuCodename,
37+ } ;
Original file line number Diff line number Diff line change 1515const fs = require ( 'fs' ) ;
1616const path = require ( 'path' ) ;
1717const { execSync } = require ( 'child_process' ) ;
18-
19- function detectUbuntuCodename ( ) {
20- if ( process . platform !== 'linux' ) {
21- return null ;
22- }
23-
24- try {
25- const osRelease = fs . readFileSync ( '/etc/os-release' , 'utf8' ) ;
26- const match = osRelease . match ( / ^ V E R S I O N _ C O D E N A M E = ( .* ) $ / m) ;
27- return match ? match [ 1 ] . trim ( ) : null ;
28- } catch {
29- return null ;
30- }
31- }
18+ const { detectUbuntuCodename } = require ( '../lib/utils' ) ;
3219
3320function getRosDistro ( ) {
3421 return process . env . ROS_DISTRO || null ;
Original file line number Diff line number Diff line change 1414
1515const fs = require ( 'fs' ) ;
1616const path = require ( 'path' ) ;
17-
18- function detectUbuntuCodename ( ) {
19- try {
20- const osRelease = fs . readFileSync ( '/etc/os-release' , 'utf8' ) ;
21- const match = osRelease . match ( / ^ V E R S I O N _ C O D E N A M E = ( .* ) $ / m) ;
22- return match ? match [ 1 ] . trim ( ) : null ;
23- } catch ( e ) {
24- return null ;
25- }
26- }
17+ const { detectUbuntuCodename } = require ( '../lib/utils' ) ;
2718
2819function tagPrebuilds ( ) {
2920 const rosDistro = process . env . ROS_DISTRO ;
You can’t perform that action at this time.
0 commit comments