From ae187b6d75c8079da0be1dc288613bad8466fe61 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Tue, 24 Oct 2023 17:43:37 +0200 Subject: Initial commit --- .../cross-spawn/lib/util/readShebang.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 desktop/node_modules/cross-spawn/lib/util/readShebang.js (limited to 'desktop/node_modules/cross-spawn/lib/util/readShebang.js') diff --git a/desktop/node_modules/cross-spawn/lib/util/readShebang.js b/desktop/node_modules/cross-spawn/lib/util/readShebang.js new file mode 100644 index 0000000..5e83733 --- /dev/null +++ b/desktop/node_modules/cross-spawn/lib/util/readShebang.js @@ -0,0 +1,23 @@ +'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; + const buffer = Buffer.alloc(size); + + 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; -- cgit