From 97f9efe6d602853b5952264eb3a63d16f3006a24 Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Tue, 9 Sep 2025 22:47:52 +0300 Subject: [PATCH 1/2] feat: inline tiny vendor deps with THIRD PARTY NOTICE --- THIRD_PARTY_NOTICES | 55 ++++++++++++++++++++++++++++++++++++++ lib/util/pathKey.js | 11 ++++++++ lib/util/readShebang.js | 2 +- lib/util/resolveCommand.js | 2 +- lib/util/shebangCommand.js | 20 ++++++++++++++ 5 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 THIRD_PARTY_NOTICES create mode 100644 lib/util/pathKey.js create mode 100644 lib/util/shebangCommand.js diff --git a/THIRD_PARTY_NOTICES b/THIRD_PARTY_NOTICES new file mode 100644 index 0000000..04cbc76 --- /dev/null +++ b/THIRD_PARTY_NOTICES @@ -0,0 +1,55 @@ +Third‑Party Notices + +This project includes portions derived from the following third‑party works. +Their licenses are reproduced below. + +------------------------------------------------------------------------------- + +shebang-command +License: MIT +Author: Kevin Mårtensson (github.com/kevva) +Source: https://github.com/kevva/shebang-command + +MIT License + +Copyright (c) Kevin Mårtensson (github.com/kevva) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +------------------------------------------------------------------------------- + +shebang-regex +License: MIT +Author: Sindre Sorhus (https://sindresorhus.com) +Source: https://github.com/sindresorhus/shebang-regex + +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +------------------------------------------------------------------------------- + +path-key +License: MIT +Author: Sindre Sorhus (https://sindresorhus.com) +Source: https://github.com/sindresorhus/path-key + +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/lib/util/pathKey.js b/lib/util/pathKey.js new file mode 100644 index 0000000..575565a --- /dev/null +++ b/lib/util/pathKey.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function pathKey(options = {}) { + const { env = process.env, platform = process.platform } = options; + + if (platform !== 'win32') { + return 'PATH'; + } + + return Object.keys(env).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path'; +}; \ No newline at end of file diff --git a/lib/util/readShebang.js b/lib/util/readShebang.js index 5e83733..864df61 100644 --- a/lib/util/readShebang.js +++ b/lib/util/readShebang.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs'); -const shebangCommand = require('shebang-command'); +const shebangCommand = require('./shebangCommand'); function readShebang(command) { // Read the first 150 bytes from the file diff --git a/lib/util/resolveCommand.js b/lib/util/resolveCommand.js index 7972455..8a38f81 100644 --- a/lib/util/resolveCommand.js +++ b/lib/util/resolveCommand.js @@ -2,7 +2,7 @@ const path = require('path'); const which = require('which'); -const getPathKey = require('path-key'); +const getPathKey = require('./pathKey'); function resolveCommandAttempt(parsed, withoutPathExt) { const env = parsed.options.env || process.env; diff --git a/lib/util/shebangCommand.js b/lib/util/shebangCommand.js new file mode 100644 index 0000000..6753bb6 --- /dev/null +++ b/lib/util/shebangCommand.js @@ -0,0 +1,20 @@ +'use strict'; + +const SHEBANG_RE = /^#!(.*)/; + +module.exports = function shebangCommand(string = '') { + const match = string.match(SHEBANG_RE); + + if (!match) { + return null; + } + + const [path, argument] = match[0].replace(/#! ?/, '').split(' '); + const binary = path.split('/').pop(); + + if (binary === 'env') { + return argument; + } + + return argument ? `${binary} ${argument}` : binary; +}; \ No newline at end of file From 5f56cc7ceae732229d7d1a325e1f4e65a88c5e33 Mon Sep 17 00:00:00 2001 From: outslept <135520429+outslept@users.noreply.github.com> Date: Tue, 9 Sep 2025 22:50:34 +0300 Subject: [PATCH 2/2] chore: remove `path-key` and `shebang-command` from the deps --- package-lock.json | 5 +++-- package.json | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c703dc..3ca740b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,6 @@ "version": "7.0.6", "license": "MIT", "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", "which": "^2.0.1" }, "devDependencies": { @@ -11399,6 +11397,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "engines": { "node": ">=8" } @@ -12289,6 +12288,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -12300,6 +12300,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "engines": { "node": ">=8" } diff --git a/package.json b/package.json index 24b2eb4..62ca8ad 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,6 @@ ] }, "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", "which": "^2.0.1" }, "devDependencies": {