Update dependency n-readlines to v3 (#18447)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
1 parent
8cd31f577c
commit
dfed96fddb
4 files changed
+49
-31
No files matched your search
+1
-1
@@ -91,7 +91,7 @@
|
||||
"meriyah": "7.0.0",
|
||||
"micromatch": "4.0.8",
|
||||
"minimist": "1.2.8",
|
||||
"n-readlines": "1.0.1",
|
||||
"n-readlines": "3.4.0",
|
||||
"outdent": "0.8.0",
|
||||
"oxc-parser": "0.101.0",
|
||||
"parse-json": "8.3.0",
|
||||
|
||||
@@ -56,9 +56,15 @@ const mainModule = {
|
||||
},
|
||||
{
|
||||
module: require.resolve("n-readlines"),
|
||||
find: "const readBuffer = new Buffer(this.options.readChunk);",
|
||||
replacement:
|
||||
"const readBuffer = Buffer.alloc(this.options.readChunk);",
|
||||
process(text) {
|
||||
text = text.replace(
|
||||
"const fs = require('fs')",
|
||||
'import fs from "node:fs"',
|
||||
);
|
||||
text = text.replace("module.exports = ", "export default ");
|
||||
|
||||
return text;
|
||||
},
|
||||
},
|
||||
// `parse-json` use another copy of `@babel/code-frame`
|
||||
{
|
||||
|
||||
@@ -1,36 +1,48 @@
|
||||
import readlines from "n-readlines";
|
||||
import { toPath } from "url-or-path";
|
||||
|
||||
/**
|
||||
* @param {string | URL} file
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function readFileFirstLine(file) {
|
||||
const liner = new readlines(toPath(file));
|
||||
const firstLineBuffer = liner.next();
|
||||
|
||||
if (typeof liner.fd === "number") {
|
||||
liner.close();
|
||||
}
|
||||
|
||||
return firstLineBuffer?.toString("utf8");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | URL} file
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function getInterpreter(file) {
|
||||
let firstLine;
|
||||
try {
|
||||
const liner = new readlines(file);
|
||||
const firstLineBuffer = liner.next();
|
||||
|
||||
if (firstLineBuffer === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
liner.close();
|
||||
|
||||
const firstLine = firstLineBuffer.toString("utf8");
|
||||
|
||||
// #!/bin/env node, #!/usr/bin/env node
|
||||
const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/u);
|
||||
if (m1) {
|
||||
return m1[1];
|
||||
}
|
||||
|
||||
// #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
|
||||
const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/u);
|
||||
if (m2) {
|
||||
return m2[1];
|
||||
}
|
||||
firstLine = readFileFirstLine(file);
|
||||
} catch {
|
||||
// couldn't open the file
|
||||
}
|
||||
|
||||
if (!firstLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
// #!/bin/env node, #!/usr/bin/env node
|
||||
const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/u);
|
||||
if (m1) {
|
||||
return m1[1];
|
||||
}
|
||||
|
||||
// #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
|
||||
const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/u);
|
||||
if (m2) {
|
||||
return m2[1];
|
||||
}
|
||||
}
|
||||
|
||||
export default getInterpreter;
|
||||
@@ -6819,10 +6819,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"n-readlines@npm:1.0.1":
|
||||
version: 1.0.1
|
||||
resolution: "n-readlines@npm:1.0.1"
|
||||
checksum: 10/4f0ddcd26347040eb219d8fc8c3620ce086095a355e64791298822b5882fdd646d69b733f6c519bcadc5c64f540e8f13a399e39cfb22e80e25a16000eca7572e
|
||||
"n-readlines@npm:3.4.0":
|
||||
version: 3.4.0
|
||||
resolution: "n-readlines@npm:3.4.0"
|
||||
checksum: 10/8655b550cf25023c5692705ff4c0829955bedaf89e8cdc19bf09ef35501dc31d5ac8e14b35d0e1d60bdb509c41637150e67b07aa0e4b5e6295c8031252fff507
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -7606,7 +7606,7 @@ __metadata:
|
||||
meriyah: "npm:7.0.0"
|
||||
micromatch: "npm:4.0.8"
|
||||
minimist: "npm:1.2.8"
|
||||
n-readlines: "npm:1.0.1"
|
||||
n-readlines: "npm:3.4.0"
|
||||
nano-spawn: "npm:2.0.0"
|
||||
node-style-text: "npm:2.1.2"
|
||||
npm-run-all2: "npm:8.0.4"
|
||||
|
||||
Reference in new issue
Block a user