mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-05-10 17:12:34 +00:00
new toolkit and scoped registries
This commit is contained in:
parent
a9f1343a9a
commit
feb12fe291
403 changed files with 81577 additions and 1990 deletions
32
node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
32
node_modules/cross-spawn/lib/util/readShebang.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const shebangCommand = require('shebang-command');
|
||||
|
||||
function readShebang(command) {
|
||||
// Read the first 150 bytes from the file
|
||||
const size = 150;
|
||||
let buffer;
|
||||
|
||||
if (Buffer.alloc) {
|
||||
// Node.js v4.5+ / v5.10+
|
||||
buffer = Buffer.alloc(size);
|
||||
} else {
|
||||
// Old Node.js API
|
||||
buffer = new Buffer(size);
|
||||
buffer.fill(0); // zero-fill
|
||||
}
|
||||
|
||||
let fd;
|
||||
|
||||
try {
|
||||
fd = fs.openSync(command, 'r');
|
||||
fs.readSync(fd, buffer, 0, size, 0);
|
||||
fs.closeSync(fd);
|
||||
} catch (e) { /* Empty */ }
|
||||
|
||||
// Attempt to extract shebang (null is returned if not a shebang)
|
||||
return shebangCommand(buffer.toString());
|
||||
}
|
||||
|
||||
module.exports = readShebang;
|
Loading…
Add table
Add a link
Reference in a new issue