nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gulpjs/vinyl-fs
Pull request #133 (2015-12-10 19:22:31)

fix TypeError when the dest sourcemaps option is a boolean
This PR fixes a TypeError that's thrown when a boolean `sourcemaps` option is passed to `dest` e.g.:

```javascript
fs.dest(dir, { sourcemaps: true })
```

### test.js

```javascript
'use strict'

let coffee = require('gulp-coffee')
let fs     = require('vinyl-fs')
let rename = require('gulp-rename')

fs.src('./input.coffee', { sourcemaps: true })
    .pipe(coffee({ sourceMap: true }))
    .pipe(rename('output.js'))
    .pipe(fs.dest('.', { sourcemaps: true }))
```

### input.coffee

```coffeescript
console.log 'Hello, world!'
```

    $ node ./test.js

### output

```
test/node_modules/gulp-sourcemaps/index.js:144
    options.includeContent = true;
                           ^

TypeError: Cannot assign to read only property 'includeContent' of true
  at Object.write (test/node_modules/gulp-sourcemaps/index.js:144:28)
  at Object.dest (test/node_modules/vinyl-fs/lib/dest/index.js:28:30)
  at Object.<anonymous> (test/test.js:10:14)
  at Module._compile (module.js:425:26)
  at Object.Module._extensions..js (module.js:432:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:313:12)
  at Function.Module.runMain (module.js:457:10)
  at startup (node.js:138:18)
  at node.js:974:3
```



Patch:
diff --git a/lib/dest/index.js b/lib/dest/index.js
index 4350c1e..ecc6ad7 100644
--- a/lib/dest/index.js
+++ b/lib/dest/index.js
@@ -25,7 +25,12 @@ function dest(outFolder, opt) {
     return saveStream;
   }
 
-  var mapStream = sourcemaps.write(opt.sourcemaps.path, opt.sourcemaps);
+  var sourcemapOpt = opt.sourcemaps;
+  if (typeof sourcemapOpt === 'boolean') {
+    sourcemapOpt = { sourcemaps: sourcemapOpt };
+  }
+
+  var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt);
   var outputStream = duplexify.obj(mapStream, saveStream);
   mapStream.pipe(saveStream);
 


Test patch:
diff --git a/test/dest.js b/test/dest.js
index 1a4445c..d094ec0 100644
--- a/test/dest.js
+++ b/test/dest.js
@@ -61,6 +61,31 @@ describe('dest stream', function() {
     }
   });
 
+  it('should not explode if the sourcemap option is true', function(done) {
+    var inputPath = path.join(__dirname, './fixtures/test.coffee');
+
+    var expectedFile = new File({
+      base: __dirname,
+      cwd: __dirname,
+      path: inputPath,
+      contents: null
+    });
+
+    var onEnd = function(){
+      buffered.length.should.equal(1);
+      buffered[0].should.equal(expectedFile);
+      done();
+    };
+
+    var stream = vfs.dest(path.join(__dirname, './out-fixtures/'), { sourcemaps: true });
+
+    var buffered = [];
+    var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
+    stream.pipe(bufferStream);
+    stream.write(expectedFile);
+    stream.end();
+  });
+
   it('should pass through writes with cwd', function(done) {
     var inputPath = path.join(__dirname, './fixtures/test.coffee');
Repository: gulpjs/vinyl-fs
Pull request #160 (2016-02-28 00:40:11)

Allow specify dest sourcemaps option as string
I think this will be much prettier and consistently.

```js
gulp.src('path', { sourcemaps: true })
  .pipe(gulp.dest('path', { sourcemaps: '.' }));
```


Patch:
diff --git a/README.md b/README.md
index 914e365..f449c6b 100644
--- a/README.md
+++ b/README.md
@@ -199,7 +199,8 @@ Default: `true` (always overwrite existing files)
 
 ##### `options.sourcemaps`
 
-Enables sourcemap support on files passed through the stream.  Will write inline soucemaps if specified as `true`. Uses [gulp-sourcemaps] under the hood.
+Enables sourcemap support on files passed through the stream.  Will write inline soucemaps if specified as `true`.
+Specifying a `string` is shorthand for the path option. Uses [gulp-sourcemaps] under the hood.
 
 Examples:
 
@@ -211,9 +212,7 @@ vfs.dest('./', {
 
 // Write as files in the same folder
 vfs.dest('./', {
-  sourcemaps: {
-    path: '.'
-  }
+  sourcemaps: '.'
 });
 
 // Any other options are passed through to [gulp-sourcemaps]
@@ -226,7 +225,7 @@ vfs.dest('./', {
 });
 ```
 
-Type: `Boolean` or `Object`
+Type: `Boolean`, `String` or `Object`
 
 Default: `undefined` (do not write sourcemaps)
 
diff --git a/lib/dest/index.js b/lib/dest/index.js
index 7f23a83..049ac96 100644
--- a/lib/dest/index.js
+++ b/lib/dest/index.js
@@ -34,6 +34,11 @@ function dest(outFolder, opt) {
   if (typeof sourcemapOpt === 'boolean') {
     sourcemapOpt = {};
   }
+  if (typeof sourcemapOpt === 'string') {
+    sourcemapOpt = {
+      path: sourcemapOpt,
+    };
+  }
 
   var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt);
   var outputStream = duplexify.obj(mapStream, saveStream);


Test patch:
diff --git a/test/dest.js b/test/dest.js
index 2aaa9df..ef0431b 100644
--- a/test/dest.js
+++ b/test/dest.js
@@ -103,6 +103,32 @@ describe('dest stream', function() {
     stream.end();
   });
 
+  it('should not explode if the sourcemap option is string', function(done) {
+    var inputPath = path.join(__dirname, './fixtures/test.coffee');
+
+    var expectedFile = new File({
+      base: __dirname,
+      cwd: __dirname,
+      path: inputPath,
+      contents: null,
+    });
+
+    var buffered = [];
+
+    var onEnd = function() {
+      buffered.length.should.equal(1);
+      buffered[0].should.equal(expectedFile);
+      done();
+    };
+
+    var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
+
+    var stream = vfs.dest(path.join(__dirname, './out-fixtures/'), { sourcemaps: '.' });
+    stream.pipe(bufferStream);
+    stream.write(expectedFile);
+    stream.end();
+  });
+
   it('should not explode if sourcemap option is an object', function(done) {
     var inputPath = path.join(__dirname, './fixtures/test.coffee');
 
diff --git a/test/not-owned/not-owned.txt b/test/not-owned/not-owned.txt
index aeeb294..88bf7d5 100644
--- a/test/not-owned/not-owned.txt
+++ b/test/not-owned/not-owned.txt
@@ -1,1 +1,1 @@
-Something new
+Something new
\ No newline at end of file
Repository: gulpjs/vinyl-fs
Pull request #342 (2023-06-11 21:35:33)

fix: Correct regression with src using arrays of globs
I broke `src()` with arrays of globs with my changes in #333

This converts all glob arguments to arrays and then normalize the entire array of globs.


Patch:
diff --git a/lib/src/index.js b/lib/src/index.js
index 99d2cda..278f3f7 100644
--- a/lib/src/index.js
+++ b/lib/src/index.js
@@ -14,6 +14,10 @@ var sourcemap = require('./sourcemap');
 var readContents = require('./read-contents');
 var resolveSymlinks = require('./resolve-symlinks');
 
+function normalize(glob) {
+  return normalizePath(glob, false);
+}
+
 function src(glob, opt) {
   var optResolver = createResolver(config, opt);
 
@@ -21,7 +25,11 @@ function src(glob, opt) {
     throw new Error('Invalid glob argument: ' + glob);
   }
 
-  glob = normalizePath(glob, false);
+  if (!Array.isArray(glob)) {
+    glob = [glob];
+  }
+
+  glob = glob.map(normalize);
 
   var outputStream = pipeline(
     gs(glob, opt),


Test patch:
diff --git a/test/src.js b/test/src.js
index eec726d..9ea2f7c 100644
--- a/test/src.js
+++ b/test/src.js
@@ -110,6 +110,16 @@ describeStreams('.src()', function (stream) {
     }
   });
 
+  it('supports arrays of globs', function (done) {
+    var cwd = path.relative(process.cwd(), __dirname);
+
+    var stream = vfs.src(['./fixtures/test.txt', './fixtures/bom-*.txt'], {
+      cwd: cwd,
+    });
+    expect(stream).toEqual(expect.anything());
+    done();
+  });
+
   it('emits an error on file not existing', function (done) {
     function assert(err) {
       expect(err).toEqual(expect.anything());
Repository: netlify/build
Pull request #4183 (2022-02-23 17:02:43)

fix: truncate headers/redirects in logs
Fixes https://github.com/netlify/build/issues/4163

This PR re-enables https://github.com/netlify/build/pull/4172, but without the bug.

Also, regression tests have now been added to make sure re-enabling this PR is now safe.

---

For us to review and ship your PR efficiently, please perform the following steps:

- [x] Open a [bug/issue](https://github.com/netlify/build/issues/new/choose) before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or something that\`s on fire 🔥 (e.g. incident related), you can skip this step.
- [x] Read the [contribution guidelines](../CONTRIBUTING.md) 📖. This ensures your code follows our style guide and
      passes our tests.
- [x] Update or add tests (if any source code was changed or added) 🧪
- [x] Update or add documentation (if features were changed or added) 📝
- [x] Make sure the status checks below are successful ✅


Patch:
diff --git a/packages/config/src/log/cleanup.js b/packages/config/src/log/cleanup.js
index 1ac6063e3..f570ffb51 100644
--- a/packages/config/src/log/cleanup.js
+++ b/packages/config/src/log/cleanup.js
@@ -48,7 +48,9 @@ export const cleanupConfig = function ({
     functions,
     functionsDirectory,
   })
-  return netlifyConfig
+  const netlifyConfigA = truncateArray(netlifyConfig, 'headers')
+  const netlifyConfigB = truncateArray(netlifyConfigA, 'redirects')
+  return netlifyConfigB
 }
 
 export const cleanupEnvironment = function (environment) {
@@ -77,3 +79,14 @@ const cleanupPlugin = function ({ package: packageName, origin, inputs = {} }) {
 const isPublicInput = function (key, input) {
   return typeof input === 'boolean'
 }
+
+// `headers` and `redirects` can be very long, which can take several minutes
+// to print in the build logs. We truncate them before logging.
+const truncateArray = function (netlifyConfig, propName) {
+  const array = netlifyConfig[propName]
+  return Array.isArray(array) && array.length > MAX_ARRAY_LENGTH
+    ? { ...netlifyConfig, [propName]: array.slice(0, MAX_ARRAY_LENGTH) }
+    : netlifyConfig
+}
+
+const MAX_ARRAY_LENGTH = 100


Test patch:
diff --git a/packages/build/tests/log/tests.js b/packages/build/tests/log/tests.js
index 73d7f9ccd..ab5995a43 100644
--- a/packages/build/tests/log/tests.js
+++ b/packages/build/tests/log/tests.js
@@ -59,12 +59,12 @@ test('Verbosity works with plugin errors', async (t) => {
   await runFixture(t, 'verbose_error', { flags: { verbose: true } })
 })
 
-test.skip('Does not truncate long headers in logs', async (t) => {
+test('Does not truncate long headers in logs', async (t) => {
   const { returnValue } = await runFixture(t, 'truncate_headers', { snapshot: false })
   t.false(returnValue.includes('999'))
 })
 
-test.skip('Does not truncate long redirects in logs', async (t) => {
+test('Does not truncate long redirects in logs', async (t) => {
   const { returnValue } = await runFixture(t, 'truncate_redirects', { snapshot: false })
   t.false(returnValue.includes('999'))
 })
Repository: eslint-community/eslint-plugin-eslint-plugin
Pull request #457 (2024-04-08 09:02:04)

fix: improve eslint rule detecting
fixes https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/455


Patch:
diff --git a/lib/utils.js b/lib/utils.js
index ae708f8..c1be12c 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -3,18 +3,19 @@
 const { getStaticValue, findVariable } = require('eslint-utils');
 const estraverse = require('estraverse');
 
+const functionTypes = new Set([
+  'FunctionExpression',
+  'ArrowFunctionExpression',
+  'FunctionDeclaration',
+]);
+
 /**
  * Determines whether a node is a 'normal' (i.e. non-async, non-generator) function expression.
  * @param {ASTNode} node The node in question
  * @returns {boolean} `true` if the node is a normal function expression
  */
 function isNormalFunctionExpression(node) {
-  const functionTypes = [
-    'FunctionExpression',
-    'ArrowFunctionExpression',
-    'FunctionDeclaration',
-  ];
-  return functionTypes.includes(node.type) && !node.generator && !node.async;
+  return functionTypes.has(node.type) && !node.generator && !node.async;
 }
 
 /**
@@ -150,12 +151,7 @@ function getRuleExportsESM(ast, scopeManager) {
           // skip if it's function-style to avoid false positives
           // refs: https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/450
           possibleNodes.push(
-            ...nodes.filter(
-              (node) =>
-                node &&
-                node.type !== 'FunctionDeclaration' &&
-                node.type !== 'FunctionExpression'
-            )
+            ...nodes.filter((node) => node && !functionTypes.has(node.type))
           );
         }
         break;


Test patch:
diff --git a/tests/lib/utils.js b/tests/lib/utils.js
index 0e8c83e..eaf7a28 100644
--- a/tests/lib/utils.js
+++ b/tests/lib/utils.js
@@ -91,6 +91,7 @@ describe('utils', () => {
         'export function foo(options) { return {}; }',
         'export async function foo(options) { return {}; }',
         'export const foo = function (options) { return {}; }',
+        'export const foo = (options) => { return {}; }',
         'export function foo(options) { return; }',
         'export function foo({opt1, opt2}) { return {}; }',
Repository: sindresorhus/execa
Pull request #215 (2019-05-07 09:31:43)

Fix `options.detached` test
This fixes the unit test for `options.detached`. The current test keeps failing on CI.

The new test takes a different approach, where we only check if a detached process is running after its parent exited, by using the `is-running` library.


Patch:
diff --git a/fixtures/detach b/fixtures/detach
index f85eb4a..7da1f8f 100755
--- a/fixtures/detach
+++ b/fixtures/detach
@@ -1,13 +1,8 @@
 #!/usr/bin/env node
-const fs = require('fs');
-const execa = require('..');
-
-const fd = fs.openSync(process.argv[2], 'w');
+'use strict';
 
-const cp = execa('noop', ['foo'], {
-	detached: true,
-	stdio: ['ignore', fd]
-});
-cp.unref();
+const execa = require('..');
 
+const subprocess = execa('node', ['./fixtures/forever'], {detached: true});
+console.log(subprocess.pid);
 process.exit();
diff --git a/fixtures/forever b/fixtures/forever
index af3141b..b64113f 100755
--- a/fixtures/forever
+++ b/fixtures/forever
@@ -1,4 +1,4 @@
 #!/usr/bin/env node
 'use strict';
 
-setTimeout(() => {}, 20000);
+setTimeout(() => {}, 1e8);
diff --git a/package.json b/package.json
index 79eef95..fed7dec 100644
--- a/package.json
+++ b/package.json
@@ -54,8 +54,8 @@
 		"coveralls": "^3.0.3",
 		"delay": "^4.1.0",
 		"is-running": "^2.1.0",
-		"nyc": "^13.3.0",
-		"tempfile": "^2.0.0",
+		"nyc": "^14.1.0",
+		"tempfile": "^3.0.0",
 		"tsd": "^0.7.1",
 		"xo": "^0.24.0"
 	},


Test patch:
diff --git a/test.js b/test.js
index abbf7d7..2cb3095 100644
--- a/test.js
+++ b/test.js
@@ -581,13 +581,12 @@ test('do not buffer when streaming', async t => {
 });
 
 test('detach child process', async t => {
-	const file = tempfile('.txt');
-
-	await execa('detach', [file]);
-
-	await delay(5000);
+	const {stdout} = await execa('detach');
+	const pid = Number(stdout);
+	t.true(Number.isInteger(pid));
+	t.true(isRunning(pid));
 
-	t.is(fs.readFileSync(file, 'utf8'), 'foo\n');
+	process.kill(pid, 'SIGKILL');
 });
 
 // See #128
Repository: sindresorhus/execa
Pull request #262 (2019-05-21 13:55:24)

Fix not being able to escape more than one space in commands
`execa('path\\ space')` works, but not `execa('path\\ with\\ multiple\\ spaces')`. This PR fixes this.

GMartigny: Looks good

Patch:
diff --git a/fixtures/command with space b/fixtures/command with space
new file mode 100755
index 0000000..e9baf7e
--- /dev/null
+++ b/fixtures/command with space
@@ -0,0 +1,3 @@
+#!/usr/bin/env node
+'use strict';
+console.log(process.argv.slice(2).join('\n'));
diff --git a/index.js b/index.js
index 3fbb537..52ffd4d 100644
--- a/index.js
+++ b/index.js
@@ -23,13 +23,13 @@ function handleEscaping(tokens, token, index) {
 		return [token];
 	}
 
-	const previousToken = tokens[index - 1];
+	const previousToken = tokens[tokens.length - 1];
 
-	if (!previousToken.endsWith('\\')) {
-		return [...tokens, token];
+	if (previousToken.endsWith('\\')) {
+		return [...tokens.slice(0, -1), `${previousToken.slice(0, -1)} ${token}`];
 	}
 
-	return [...tokens.slice(0, index - 1), `${previousToken.slice(0, -1)} ${token}`];
+	return [...tokens, token];
 }
 
 function parseCommand(command, args = []) {


Test patch:
diff --git a/test.js b/test.js
index 5b8bb65..aeefcc7 100644
--- a/test.js
+++ b/test.js
@@ -123,6 +123,11 @@ test('escape other whitespaces in string arguments', async t => {
 	t.is(stdout, 'foo\tbar');
 });
 
+test('allow escaping spaces in commands', async t => {
+	const {stdout} = await execa('./fixtures/command\\ with\\ space foo bar');
+	t.is(stdout, 'foo\nbar');
+});
+
 test('allow escaping spaces in string arguments', async t => {
 	const {stdout} = await execa('node fixtures/echo foo\\ bar');
 	t.is(stdout, 'foo bar');
Repository: sindresorhus/execa
Pull request #266 (2019-05-29 18:24:52)

Make errors more consistent
When the underlying `child_process.spawn()` throws synchronously, the promise rejected by `execa()` has a different shape than other errors. This fixes it.

No documentation not TypeScript types needs to be added since it merely adjust the code behavior to what's already documented.


Patch:
diff --git a/index.js b/index.js
index bb3d217..0bdf148 100644
--- a/index.js
+++ b/index.js
@@ -218,7 +218,13 @@ const execa = (file, args, options) => {
 	try {
 		spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
 	} catch (error) {
-		return Promise.reject(error);
+		return Promise.reject(makeError({error, stdout: '', stderr: '', all: ''}, {
+			joinedCommand,
+			parsed,
+			timedOut: false,
+			isCanceled: false,
+			killed: false
+		}));
 	}
 
 	// #115


Test patch:
diff --git a/test.js b/test.js
index aa74acd..fb0cd8a 100644
--- a/test.js
+++ b/test.js
@@ -217,6 +217,18 @@ test('execa() returns a promise with kill() and pid', t => {
 	t.is(typeof pid, 'number');
 });
 
+test('child_process.spawn() errors are propagated', async t => {
+	const {exitCodeName} = await t.throwsAsync(execa('noop', {uid: -1}));
+	t.is(exitCodeName, process.platform === 'win32' ? 'ENOTSUP' : 'EINVAL');
+});
+
+test('child_process.spawnSync() errors are propagated', t => {
+	const {exitCodeName} = t.throws(() => {
+		execa.sync('noop', {uid: -1});
+	});
+	t.is(exitCodeName, process.platform === 'win32' ? 'ENOTSUP' : 'EINVAL');
+});
+
 test('maxBuffer affects stdout', async t => {
 	await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);
 	await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));
Repository: sindresorhus/execa
Pull request #280 (2019-06-10 17:44:37)

Refactor `kill()` again
This is a follow-up to #272 adding more refactoring to `kill()`.

@zokker13 	

ehmicky: Ready for another round of code review.
ehmicky: Fixed.
sindresorhus: > You should also check that it's the correct error /non-negative integer/
ehmicky: Fixed.

Patch:
diff --git a/index.js b/index.js
index b937e39..fe0d0a2 100644
--- a/index.js
+++ b/index.js
@@ -14,6 +14,7 @@ const onExit = require('signal-exit');
 const stdio = require('./lib/stdio');
 
 const TEN_MEGABYTES = 1000 * 1000 * 10;
+const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
 
 const SPACES_REGEXP = / +/g;
 
@@ -224,18 +225,27 @@ function setKillTimeout(kill, signal, options, killResult) {
 		return;
 	}
 
-	const forceKillAfter = Number.isInteger(options.forceKillAfter) ?
-		options.forceKillAfter :
-		5000;
-	setTimeout(() => kill('SIGKILL'), forceKillAfter).unref();
+	const timeout = getForceKillAfterTimeout(options);
+	setTimeout(() => {
+		kill('SIGKILL');
+	}, timeout).unref();
 }
 
-function shouldForceKill(signal, options, killResult) {
-	return ((typeof signal === 'string' &&
-		signal.toUpperCase() === 'SIGTERM') ||
-		signal === os.constants.signals.SIGTERM) &&
-		options.forceKill !== false &&
-		killResult;
+function shouldForceKill(signal, {forceKill}, killResult) {
+	return isSigterm(signal) && forceKill !== false && killResult;
+}
+
+function isSigterm(signal) {
+	return signal === os.constants.signals.SIGTERM ||
+		(typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
+}
+
+function getForceKillAfterTimeout({forceKillAfter = DEFAULT_FORCE_KILL_TIMEOUT}) {
+	if (!Number.isInteger(forceKillAfter) || forceKillAfter < 0) {
+		throw new TypeError(`Expected the \`forceKillAfter\` option to be a non-negative integer, got \`${forceKillAfter}\` (${typeof forceKillAfter})`);
+	}
+
+	return forceKillAfter;
 }
 
 const execa = (file, args, options) => {


Test patch:
diff --git a/test.js b/test.js
index 04bd470..718e32a 100644
--- a/test.js
+++ b/test.js
@@ -175,6 +175,18 @@ if (process.platform !== 'win32') {
 		const {signal} = await t.throwsAsync(subprocess);
 		t.is(signal, 'SIGKILL');
 	});
+
+	test('.kill() `forceKillAfter` should not be a float', t => {
+		t.throws(() => {
+			execa('noop').kill('SIGTERM', {forceKillAfter: 0.5});
+		}, {instanceOf: TypeError, message: /non-negative integer/});
+	});
+
+	test('.kill() `forceKillAfter` should not be negative', t => {
+		t.throws(() => {
+			execa('noop').kill('SIGTERM', {forceKillAfter: -1});
+		}, {instanceOf: TypeError, message: /non-negative integer/});
+	});
 }
 
 test('stripFinalNewline: true', async t => {