ronantakizawa/codereview-bench huggingface dataset:
Repository: nodejs/node
File: test/js-native-api/test_dataview/test.js (JavaScript)

Code before:
'use strict';
const common = require('../../common');
const assert = require('assert');

// Testing api calls for arrays
const test_dataview = require(`./build/${common.buildType}/test_dataview`);

// Test for creating dataview with ArrayBuffer
{
  const buffer = new ArrayBuffer(128);
  const template = Reflect.construct(DataView, [buffer]);

  const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
  assert.ok(theDataview instanceof DataView,
            `Expect ${theDataview} to be a DataView`);
}

// Test for creating dataview with SharedArrayBuffer
{
  const buffer = new SharedArrayBuffer(128);
  const template = Reflect.construct(DataView, [buffer]);

  const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
  assert.ok(theDataview instanceof DataView,
            `Expect ${theDataview} to be a DataView`);

  assert.strictEqual(template.buffer, theDataview.buffer);
}

// Test for creating dataview with ArrayBuffer and invalid range
{
  const buffer = new ArrayBuffer(128);
  assert.throws(() => {
    test_dataview.CreateDataView(buffer, 10, 200);
  }, RangeError);
}

// Test for creating dataview with SharedArrayBuffer and invalid range
{
  const buffer = new SharedArrayBuffer(128);
  assert.throws(() => {
    test_dataview.CreateDataView(buffer, 10, 200);
  }, RangeError);
}


Review comment (suggestion):
I think this is following the case above. But it does not seem to be necessary with `Reflect.construct`:


```suggestion
  const template = new DataView(buffer);
```

Code after:
'use strict';
const common = require('../../common');
const assert = require('assert');

// Testing api calls for arrays
const test_dataview = require(`./build/${common.buildType}/test_dataview`);

// Test for creating dataview with ArrayBuffer
{
  const buffer = new ArrayBuffer(128);
  const template = Reflect.construct(DataView, [buffer]);

  const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
  assert.ok(theDataview instanceof DataView,
            `Expect ${theDataview} to be a DataView`);
}

// Test for creating dataview with SharedArrayBuffer
{
  const buffer = new SharedArrayBuffer(128);
  const template = new DataView(buffer);

  const theDataview = test_dataview.CreateDataViewFromJSDataView(template);
  assert.ok(theDataview instanceof DataView,
            `Expect ${theDataview} to be a DataView`);

  assert.strictEqual(template.buffer, theDataview.buffer);
}

// Test for creating dataview with ArrayBuffer and invalid range
{
  const buffer = new ArrayBuffer(128);
  assert.throws(() => {
    test_dataview.CreateDataView(buffer, 10, 200);
  }, RangeError);
}

// Test for creating dataview with SharedArrayBuffer and invalid range
{
  const buffer = new SharedArrayBuffer(128);
  assert.throws(() => {
    test_dataview.CreateDataView(buffer, 10, 200);
  }, RangeError);
}
Repository: nodejs/node
File: src/node_modules.cc (C++)

Code before:

  return nullptr;
}

void BindingData::GetNearestParentPackageJSONType(
    const FunctionCallbackInfo<Value>& args) {
  CHECK_GE(args.Length(), 1);
  CHECK(args[0]->IsString());

  Realm* realm = Realm::GetCurrent(args);
  BufferValue path_value(realm->isolate(), args[0]);
  // Check if the path has a trailing slash. If so, add it after
  // ToNamespacedPath() as it will be deleted by ToNamespacedPath()
  bool slashCheck = path_value.ToStringView().ends_with(kPathSeparator);

  ToNamespacedPath(realm->env(), &path_value);

  std::string path_value_str = path_value.ToString();
  if (slashCheck) {
    path_value_str.push_back(kPathSeparator);
  }

  std::filesystem::path path;

#ifdef _WIN32
  std::wstring wide_path = ConvertToWideString(path_value_str, CP_UTF8);
  path = std::filesystem::path(wide_path);
#else
  path = std::filesystem::path(path_value_str);
#endif

  auto package_json = TraverseParent(realm, path);

  if (package_json == nullptr) {
    return;
  }

  Local<Value> value;
  if (ToV8Value(realm->context(), package_json->type).ToLocal(&value)) {
    args.GetReturnValue().Set(value);
  }
}

template <bool return_only_type>
void BindingData::GetPackageScopeConfig(
    const FunctionCallbackInfo<Value>& args) {
  CHECK_GE(args.Length(), 1);
  CHECK(args[0]->IsString());

  Realm* realm = Realm::GetCurrent(args);
  Utf8Value resolved(realm->isolate(), args[0]);

Review comment (suggestion):
Ditto here - I think we can just create `StringToPath` and let `BufferValueToPath` use it, and here it can just use `StringToPath`

Code after:
  // Check if the path has a trailing slash. If so, add it after
  // ToNamespacedPath() as it will be deleted by ToNamespacedPath()
  bool slashCheck = path_value.ToStringView().ends_with(kPathSeparator);

  ToNamespacedPath(realm->env(), &path_value);

  auto path = path_value.ToPath();

  if (slashCheck) {
    path /= "";
  }

  auto package_json = TraverseParent(realm, path);

  if (package_json == nullptr) {
    return;
  }

  Local<Value> value;
  if (ToV8Value(realm->context(), package_json->type).ToLocal(&value)) {
    args.GetReturnValue().Set(value);
  }
}

template <bool return_only_type>
void BindingData::GetPackageScopeConfig(
    const FunctionCallbackInfo<Value>& args) {
  CHECK_GE(args.Length(), 1);
  CHECK(args[0]->IsString());

  Realm* realm = Realm::GetCurrent(args);
  Utf8Value resolved(realm->isolate(), args[0]);
  auto package_json_url_base = ada::parse(resolved.ToStringView());
  if (!package_json_url_base) {
    url::ThrowInvalidURL(realm->env(), resolved.ToStringView(), std::nullopt);
    return;
  }
  auto package_json_url =
      ada::parse("./package.json", &package_json_url_base.value());
  if (!package_json_url) {
    url::ThrowInvalidURL(realm->env(), "./package.json", resolved.ToString());
    return;
  }

  std::string_view node_modules_package_path = "/node_modules/package.json";
  auto error_context = ErrorContext();
  error_context.is_esm = true;

  // TODO(@anonrig): Rewrite this function and avoid calling URL parser.
  while (true) {
    auto pathname = package_json_url->get_pathname();
Repository: nodejs/node
File: test/parallel/test-http-set-trailers.js (JavaScript)

Code before:
    callback();
  }));
}

// Now, we test an HTTP/1.1 request.
function testHttp11(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  let tid;
  c.on('connect', function() {
    c.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
    tid = setTimeout(common.mustNotCall(), 2000, 'Couldn\'t find last chunk.');
  });

  let res_buffer = '';
  c.on('data', common.mustCallAtLeast((chunk) => {
    res_buffer += chunk;
    if (/0\r\n/.test(res_buffer)) { // got the end.
      clearTimeout(tid);
      assert.match(
        res_buffer,
        /0\r\nx-foo: bar\r\n\r\n$/,
      );
      callback();
    }
  }));
}

// Now, see if the client sees the trailers.
function testClientTrailers(port, callback) {
  http.get({ port, path: '/hello', headers: {} }, common.mustCall((res) => {
    res.on('end', common.mustCall(() => {
      assert.ok('x-foo' in res.trailers,
                `${util.inspect(res.trailers)} misses the 'x-foo' property`);
      callback();
    }));
    res.resume();
  }));
}

const server = http.createServer((req, res) => {
  res.writeHead(200, [['content-type', 'text/plain']]);
  res.addTrailers({ 'x-foo': 'bar' });
  res.end('stuff\n');
});
server.listen(0, () => {
  Promise.all([testHttp10, testHttp11, testClientTrailers]
    .map((f) => util.promisify(f))
    .map((f) => f(server.address().port)))

Review comment (suggestion):
Is there a reason to remove the messages? The `AssertionError`s already have the regex and tested string in `expected` and `actual` properties, making default message not more informative.
```suggestion
      assert.match(
        res_buffer,
        /0\r\nx-foo: bar\r\n\r\n$/,
        'No trailer in HTTP/1.1 response',
```

Code after:
    );
    callback();
  }));
}

// Now, we test an HTTP/1.1 request.
function testHttp11(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  let tid;
  c.on('connect', function() {
    c.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
    tid = setTimeout(common.mustNotCall(), 2000, 'Couldn\'t find last chunk.');
  });

  let res_buffer = '';
  c.on('data', common.mustCallAtLeast((chunk) => {
    res_buffer += chunk;
    if (/0\r\n/.test(res_buffer)) { // got the end.
      clearTimeout(tid);
      // Ensure trailer being in HTTP/1.1 response
      assert.match(
        res_buffer,
        /0\r\nx-foo: bar\r\n\r\n$/,
      );
      callback();
    }
  }));
}

// Now, see if the client sees the trailers.
function testClientTrailers(port, callback) {
  http.get({ port, path: '/hello', headers: {} }, common.mustCall((res) => {
    res.on('end', common.mustCall(() => {
      assert.ok('x-foo' in res.trailers,
                `${util.inspect(res.trailers)} misses the 'x-foo' property`);
      callback();
    }));
    res.resume();
  }));
}

const server = http.createServer((req, res) => {
  res.writeHead(200, [['content-type', 'text/plain']]);
  res.addTrailers({ 'x-foo': 'bar' });
  res.end('stuff\n');
});
server.listen(0, () => {
  Promise.all([testHttp10, testHttp11, testClientTrailers]
Repository: nodejs/node
File: test/parallel/test-http-set-trailers.js (JavaScript)

Code before:
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');
const util = require('util');

// First, we test an HTTP/1.0 request.
function testHttp10(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  c.on('connect', () => {
    c.write('GET / HTTP/1.0\r\n\r\n');
  });

  let res_buffer = '';
  c.on('data', (chunk) => {
    res_buffer += chunk;
  });

  c.on('end', common.mustCall(() => {
    c.end();
    assert.doesNotMatch(
      res_buffer,
      /x-foo/,
    );
    callback();
  }));
}

// Now, we test an HTTP/1.1 request.
function testHttp11(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  let tid;
  c.on('connect', function() {
    c.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
    tid = setTimeout(common.mustNotCall(), 2000, 'Couldn\'t find last chunk.');
  });

  let res_buffer = '';
  c.on('data', common.mustCallAtLeast((chunk) => {
    res_buffer += chunk;
    if (/0\r\n/.test(res_buffer)) { // got the end.
      clearTimeout(tid);
      assert.match(
        res_buffer,

Review comment (suggestion):
```suggestion
    // Ensure no trailer being in HTTP/1.0 response
    assert.doesNotMatch(
```

Code after:
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');
const util = require('util');

// First, we test an HTTP/1.0 request.
function testHttp10(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  c.on('connect', () => {
    c.write('GET / HTTP/1.0\r\n\r\n');
  });

  let res_buffer = '';
  c.on('data', (chunk) => {
    res_buffer += chunk;
  });

  c.on('end', common.mustCall(() => {
    c.end();
    // Ensure no trailer being in HTTP/1.0 response
    assert.doesNotMatch(
      res_buffer,
      /x-foo/,
    );
    callback();
  }));
}

// Now, we test an HTTP/1.1 request.
function testHttp11(port, callback) {
  const c = net.createConnection(port);

  c.setEncoding('utf8');

  let tid;
  c.on('connect', function() {
    c.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
    tid = setTimeout(common.mustNotCall(), 2000, 'Couldn\'t find last chunk.');
  });

  let res_buffer = '';
  c.on('data', common.mustCallAtLeast((chunk) => {
    res_buffer += chunk;
    if (/0\r\n/.test(res_buffer)) { // got the end.
      clearTimeout(tid);
      // Ensure trailer being in HTTP/1.1 response
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

REPO_URL="https://github.com/tc39/source-map-tests.git"
TARGET_DIR="$(dirname "$0")/../../test/fixtures/test426"
TMP_DIR="$(mktemp -d)"

git clone --depth=1 "$REPO_URL" "$TMP_DIR"

rsync -a --delete --exclude='.git' "$TMP_DIR"/ "$TARGET_DIR"/

rm -rf "$TMP_DIR"

echo "test426 fixtures updated from $REPO_URL."


Review comment (suggestion):
If instead of using `git clone`, we use the tarball, we don't need to worry about the `.git` folder and we get the sha:

```sh
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

curl -f "$TARBALL_URL" | tar -xz

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

TARGET_DIR="$(dirname "$0")/../../test/fixtures/test426"
README="$(dirname "$0")/../../test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"
curl -f "$TARBALL_URL" | tar -xzf - -C "$TMP_DIR"

rsync -a --delete "$TMP_DIR"/source-map-tests-"$SHA"/ "$TARGET_DIR"/

rm -rf "$TMP_DIR"

sed -i.bak "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README"
rm "$README.bak"

echo "test426 fixtures updated to $SHA."


Review comment (suggestion):
```suggestion
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
```

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

TARGET_DIR="$(dirname "$0")/../../test/fixtures/test426"
README="$(dirname "$0")/../../test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"
curl -f "$TARBALL_URL" | tar -xzf - -C "$TMP_DIR"

rsync -a --delete "$TMP_DIR"/source-map-tests-"$SHA"/ "$TARGET_DIR"/

rm -rf "$TMP_DIR"

sed -i.bak "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README"
rm "$README.bak"

echo "test426 fixtures updated to $SHA."


Review comment (suggestion):

```suggestion
# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
```

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

TARGET_DIR="$(dirname "$0")/../../test/fixtures/test426"
README="$(dirname "$0")/../../test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"
curl -f "$TARBALL_URL" | tar -xzf - -C "$TMP_DIR"

rsync -a --delete "$TMP_DIR"/source-map-tests-"$SHA"/ "$TARGET_DIR"/

rm -rf "$TMP_DIR"

sed -i.bak "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README"
rm "$README.bak"

echo "test426 fixtures updated to $SHA."


Review comment (suggestion):
IIRC `-i` is not portable, and IMO it's more readable to explicitly use a temp file here
```suggestion
TMP_FILE=$(mktemp)
sed "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"
```

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

TARGET_DIR="$(dirname "$0")/../../test/fixtures/test426"
README="$(dirname "$0")/../../test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"
curl -f "$TARBALL_URL" | tar -xzf - -C "$TMP_DIR"

rsync -a --delete "$TMP_DIR"/source-map-tests-"$SHA"/ "$TARGET_DIR"/

rm -rf "$TMP_DIR"

sed -i.bak "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README"
rm "$README.bak"

echo "test426 fixtures updated to $SHA."


Review comment (suggestion):
```suggestion
rsync -a --delete "$TMP_DIR/source-map-tests-$SHA/" "$TARGET_DIR/"
```
AFAICT we're not using `rsync` anywhere, so that's a new dependency. Have you tried instead:
```suggestion
rm -rf "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"
```

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"
Repository: nodejs/node
File: tools/dep_updaters/update-test426-fixtures.sh (Shell)

Code before:
#!/bin/sh

set -e

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

rm -rf "$TMP_DIR"

TMP_FILE=$(mktemp)
sed "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

echo "test426 fixtures updated to $SHA."


Review comment (suggestion):
```suggestion
CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi
```

Code after:
#!/bin/sh

set -ex

BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")

if [ "$CURRENT_SHA" = "$SHA" ]; then
  echo "Already up-to-date"
  exit 0
fi

rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"
mv "$TMP_FILE" "$README"

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$SHA"