This change detects if the user has `protoc` available and, if so, uses it to generate `.pb.dart` files. If not, pre-built files are used instead.
		
			
				
	
	
		
			19 lines
		
	
	
		
			439 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			439 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
var which = require('which');
 | 
						|
var spawnSync = require('child_process').spawnSync;
 | 
						|
 | 
						|
module.exports.detect = function() {
 | 
						|
  var PROTOC = false;
 | 
						|
  try {
 | 
						|
    var bin = 'protoc';
 | 
						|
    which.sync(bin);
 | 
						|
    var version = spawnSync(bin, ['--version']).stdout.toString().replace(/\n/g, '');
 | 
						|
    PROTOC = {
 | 
						|
      bin: bin,
 | 
						|
      version: version
 | 
						|
    };
 | 
						|
  } catch (e) {
 | 
						|
    // Ignore, just return `false` instead of an object.
 | 
						|
  }
 | 
						|
  return PROTOC;
 | 
						|
};
 |