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

Resolves the issues with +x on npm #71

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions index.js
Expand Up @@ -35,6 +35,10 @@ module.exports = (target, opts) => {
args.push('/c', 'start', '""');
target = target.replace(/&/g, '^&');

if (opts.hidden) {
args.push('/B');
}

if (opts.wait) {
args.push('/wait');
}
Expand All @@ -47,14 +51,15 @@ module.exports = (target, opts) => {
args = args.concat(appArgs);
}
} else {
if (appArgs.length > 0) {
args = args.concat(appArgs);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because unshifting (pushing to the front) of an array that isn't yet created is a bad idea. We'd otherwise get clobbered.


if (opts.app) {
cmd = opts.app;
} else {
cmd = path.join(__dirname, 'xdg-open');
}

if (appArgs.length > 0) {
args = args.concat(appArgs);
cmd = path.join('/usr', 'bin', 'env');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use something like which here to ensure that we don't use the wrong path.

args.unshift('xdg-open');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not cmd = path.join('/usr', 'bin', 'env', 'xdg-open');?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because xdg-open is the argument to /usr/bin/env there is no app called /usr/bin/env/xdg-open Try running /usr/bin/env xdg-open "http://www.google.com", now try /usr/bin/env/xdg-open "http://www.google.com"

}

if (!opts.wait) {
Expand Down