fix: EINVAL when spawning cmd files on Windows (#41893)
fix: EINVAL when spawning on Windows
This commit is contained in:
		
					parent
					
						
							
								67ba30402b
							
						
					
				
			
			
				commit
				
					
						c4aeb17245
					
				
			
		
					 5 changed files with 12 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -75,7 +75,8 @@ function spawnAndCheckExitCode (cmd, args, opts) {
 | 
			
		|||
 | 
			
		||||
function cpplint (args) {
 | 
			
		||||
  args.unshift(`--root=${SOURCE_ROOT}`);
 | 
			
		||||
  const result = childProcess.spawnSync(IS_WINDOWS ? 'cpplint.bat' : 'cpplint.py', args, { encoding: 'utf8', shell: true });
 | 
			
		||||
  const cmd = IS_WINDOWS ? 'cpplint.bat' : 'cpplint.py';
 | 
			
		||||
  const result = childProcess.spawnSync(cmd, args, { encoding: 'utf8', shell: true });
 | 
			
		||||
  // cpplint.py writes EVERYTHING to stderr, including status messages
 | 
			
		||||
  if (result.stderr) {
 | 
			
		||||
    for (const line of result.stderr.split(/[\r\n]+/)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,8 @@ async function main () {
 | 
			
		|||
  const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--verbose', '--directory', 'test', '-j', 'max'], {
 | 
			
		||||
    env,
 | 
			
		||||
    cwd: NAN_DIR,
 | 
			
		||||
    stdio: 'inherit'
 | 
			
		||||
    stdio: 'inherit',
 | 
			
		||||
    shell: process.platform === 'win32'
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  if (buildStatus !== 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +105,8 @@ async function main () {
 | 
			
		|||
  const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install'], {
 | 
			
		||||
    env,
 | 
			
		||||
    cwd: NAN_DIR,
 | 
			
		||||
    stdio: 'inherit'
 | 
			
		||||
    stdio: 'inherit',
 | 
			
		||||
    shell: process.platform === 'win32'
 | 
			
		||||
  });
 | 
			
		||||
  if (installStatus !== 0) {
 | 
			
		||||
    console.error('Failed to install nan node_modules');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,8 @@ if (fs.existsSync(checkPath)) {
 | 
			
		|||
    command.slice(1),
 | 
			
		||||
    {
 | 
			
		||||
      stdio: 'inherit',
 | 
			
		||||
      cwd: checkPath
 | 
			
		||||
      cwd: checkPath,
 | 
			
		||||
      shell: process.platform === 'win32'
 | 
			
		||||
    }
 | 
			
		||||
  );
 | 
			
		||||
  child.on('exit', code => process.exit(code));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -221,7 +221,8 @@ async function installSpecModules (dir) {
 | 
			
		|||
  const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
 | 
			
		||||
    env,
 | 
			
		||||
    cwd: dir,
 | 
			
		||||
    stdio: 'inherit'
 | 
			
		||||
    stdio: 'inherit',
 | 
			
		||||
    shell: process.platform === 'win32'
 | 
			
		||||
  });
 | 
			
		||||
  if (status !== 0 && !process.env.IGNORE_YARN_INSTALL_ERROR) {
 | 
			
		||||
    console.log(`${fail} Failed to yarn install in '${dir}'`);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,8 @@ if (require.main === module) {
 | 
			
		|||
    env: {
 | 
			
		||||
      ...process.env,
 | 
			
		||||
      npm_config_yes: 'true'
 | 
			
		||||
    }
 | 
			
		||||
    },
 | 
			
		||||
    shell: process.platform === 'win32'
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  child.on('exit', code => process.exit(code));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue