@@ -19,40 +19,22 @@ const os = require('os');
1919const path = require ( 'path' ) ;
2020const child = require ( 'child_process' ) ;
2121
22- // var platform = os.platform();
22+ var platform = os . platform ( ) ;
2323var rootDir = path . dirname ( __dirname ) ;
2424var testCppDir = path . join ( rootDir , 'test' , 'cpp' ) ;
2525
26- function getExecutable ( input ) {
27- if ( os . platform ( ) === 'win32' )
28- return input + '.exe' ;
29-
30- return input ;
31- }
32-
33- var publisher = getExecutable ( 'publisher_msg' ) ;
34- var subscription = getExecutable ( 'subscription_msg' ) ;
35- var listener = getExecutable ( 'listener' ) ;
36- var client = getExecutable ( 'add_two_ints_client' ) ;
37-
38- function getExecutablePath ( input ) {
39- var releaseDir = '' ;
40- if ( os . platform ( ) === 'win32' )
41- releaseDir = 'Release' ;
42-
43- return path . join ( rootDir , 'build' , 'cpp_nodes' , releaseDir , input ) ;
44- }
45-
46- var publisherPath = getExecutablePath ( publisher ) ;
47- var subscriptionPath = getExecutablePath ( subscription ) ;
48- var listenerPath = getExecutablePath ( listener ) ;
49- var clientPath = getExecutablePath ( client ) ;
26+ var publisher = ( platform === 'win32' ) ? 'publisher_msg.exe' : 'publisher_msg' ;
27+ var subscription = ( platform === 'win32' ) ? 'subscription_msg.exe' : 'subscription_msg' ;
5028
29+ var publisherPath = path . join ( rootDir , 'build' , 'cpp_nodes' ,
30+ ( platform === 'win32' ) ? 'Release' : '' , publisher ) ;
31+ var subscriptionPath = path . join ( rootDir , 'build' , 'cpp_nodes' ,
32+ ( platform === 'win32' ) ? 'Release' : '' , subscription ) ;
5133
5234function copyFile ( platform , srcFile , destFile ) {
5335 // eslint-disable-next-line
5436 if ( ! fs . existsSync ( destFile ) ) {
55- if ( os . platform ( ) === 'win32' ) {
37+ if ( platform === 'win32' ) {
5638 child . spawn ( 'cmd.exe' , [ '/c' , `copy ${ srcFile } ${ destFile } ` ] ) ;
5739 } else {
5840 child . spawn ( 'sh' , [ '-c' , `cp ${ srcFile } ${ destFile } ` ] ) ;
@@ -62,18 +44,16 @@ function copyFile(platform, srcFile, destFile) {
6244
6345function copyAll ( fileList , dest ) {
6446 fileList . forEach ( ( file ) => {
65- copyFile ( os . platform ( ) , file , path . join ( dest , path . basename ( file ) ) ) ;
47+ copyFile ( platform , file , path . join ( dest , path . basename ( file ) ) ) ;
6648 } ) ;
6749}
6850
6951// eslint-disable-next-line
70- if ( ! fs . existsSync ( publisherPath ) && ! fs . existsSync ( subscriptionPath ) &&
71- // eslint-disable-next-line
72- ! fs . existsSync ( listenerPath ) && ! fs . existsSync ( clientPath ) ) {
52+ if ( ! fs . existsSync ( publisherPath ) && ! fs . existsSync ( subscriptionPath ) ) {
7353 var compileProcess = child . spawn ( 'ament' , [ 'build' , testCppDir , '--skip-install' ] ) ;
7454 compileProcess . on ( 'close' , ( code ) => {
75- copyAll ( [ publisherPath , subscriptionPath , listenerPath , clientPath ] , testCppDir ) ;
55+ copyAll ( [ publisherPath , subscriptionPath ] , testCppDir ) ;
7656 } ) ;
7757} else {
78- copyAll ( [ publisherPath , subscriptionPath , , listenerPath , clientPath ] , testCppDir ) ;
58+ copyAll ( [ publisherPath , subscriptionPath ] , testCppDir ) ;
7959}
0 commit comments