1+ const path = require ( 'path' ) ;
2+ const { promises : fs } = require ( 'fs' ) ;
3+ const { spawn : spawnSync } = require ( 'child_process' ) ;
4+
5+ const spawn = ( ...args ) => new Promise ( ( resolve , reject ) => {
6+ let stdout = Buffer . alloc ( 0 ) ;
7+ let stderr = Buffer . alloc ( 0 ) ;
8+ const child = spawnSync ( ...args ) ;
9+ const concat = ( o ) => ( b ) => o = Buffer . concat ( [ o , b ] ) ;
10+ child . stdout . on ( 'data' , concat ( stdout ) ) ;
11+ child . stderr . on ( 'data' , concat ( stderr ) ) ;
12+ child . on ( 'close' , function ( code ) {
13+ if ( code !== 0 ) {
14+ reject ( stderr ? new Error ( stderr . toString ( ) ) : new Error ( `Command ${ command } failed ${ code } ` ) ) ;
15+ } else {
16+ resolve ( stdout ) ;
17+ }
18+ } ) ;
19+ child . on ( 'error' , function ( error ) {
20+ reject ( error ) ;
21+ } )
22+ } ) ;
23+
24+ module . exports . spawn = spawn ;
25+
26+ const exists = async ( filePath ) => fs . access ( filePath ) . then ( ( ) => true ) . catch ( e => e . code !== 'ENOENT' ) ;
27+
28+ module . exports . exists = exists ;
29+
30+ const exe = process . platform === 'win32' ? '.exe' : '' ;
31+ const paths = {
32+ submodule : path . join ( __dirname , 'deps' , 'dump_syms' ) ,
33+ bin : path . join ( __dirname , 'bin' , `${ process . platform } -${ process . arch } ` ) ,
34+ build : path . join ( __dirname , 'build' ) ,
35+ exeOut : path . join ( __dirname , 'build' , 'release' , `dump_syms${ exe } ` ) ,
36+ exeFinal : path . join ( __dirname , 'bin' , `${ process . platform } -${ process . arch } ` , `dump_syms${ exe } ` ) ,
37+ } ;
38+
39+ module . exports . paths = paths ;
0 commit comments