Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shebang): add support for env's split-string option #195

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion lib/rules/shebang.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const getNpmignore = require("../util/get-npmignore")

const NODE_SHEBANG = "#!/usr/bin/env node\n"
const SHEBANG_PATTERN = /^(#!.+?)?(\r)?\n/u
const NODE_SHEBANG_PATTERN = /#!\/usr\/bin\/env node(?: [^\r\n]+?)?\n/u
const NODE_SHEBANG_PATTERN =
/^#!\/usr\/bin\/env(?: -\S+)*(?: \S+=\S+)* node(?: [^\r\n]+?)?\n/u
scagood marked this conversation as resolved.
Show resolved Hide resolved

function simulateNodeResolutionAlgorithm(filePath, binField) {
const possibilities = [filePath]
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/rules/shebang.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@ ruleTester.run("shebang", rule, {
filename: fixture("object-bin/bin/b.js"),
code: "#!/usr/bin/env node\nhello();",
},
{
name: "string-bin/bin/test.js",
filename: fixture("string-bin/bin/test.js"),
code: "#!/usr/bin/env -S node\nhello();",
},
{
name: "string-bin/bin/test.js",
filename: fixture("string-bin/bin/test.js"),
code: "#!/usr/bin/env -S node --loader tsm\nhello();",
},
{
name: "string-bin/bin/test.js",
filename: fixture("string-bin/bin/test.js"),
code: "#!/usr/bin/env --ignore-environment node\nhello();",
},
{
name: "string-bin/bin/test.js",
filename: fixture("string-bin/bin/test.js"),
code: "#!/usr/bin/env -i -S node --loader tsm\nhello();",
},
{
name: "string-bin/bin/test.js",
filename: fixture("string-bin/bin/test.js"),
code: "#!/usr/bin/env --block-signal=SIGINT -S FOO=bar node --loader tsm\nhello();",
},
{
name: "object-bin/bin/c.js",
filename: fixture("object-bin/bin/c.js"),
Expand Down