Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions THIRD_PARTY_NOTICES
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (github.com/kevva)
Source: https://github.com/kevva/shebang-command

MIT License

Copyright (c) Kevin Mårtensson <[email protected]> (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 <[email protected]> (https://sindresorhus.com)
Source: https://github.com/sindresorhus/shebang-regex

MIT License

Copyright (c) Sindre Sorhus <[email protected]> (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 <[email protected]> (https://sindresorhus.com)
Source: https://github.com/sindresorhus/path-key

MIT License

Copyright (c) Sindre Sorhus <[email protected]> (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.
11 changes: 11 additions & 0 deletions lib/util/pathKey.js
Original file line number Diff line number Diff line change
@@ -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';
};
2 changes: 1 addition & 1 deletion lib/util/readShebang.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/util/resolveCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions lib/util/shebangCommand.js
Original file line number Diff line number Diff line change
@@ -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;
};
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
]
},
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"devDependencies": {
Expand Down