sindresorhus/opn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Ability to pass args directly to open #183

jennifer-shehane posted onGitHub

We want the ability to pass our own flags to open, specifically the -R flag if we detect it is on darwin os. https://github.com/sindresorhus/open/issues/175

Can you allow passing along flags to open as part of the options?

const opn = require('opn')

if (os.platform() === 'darwin') {
  return opn('../foo', { args: '-R'})
}

return opn('../foo')

If you only want it for macOS, why not just cal open -R directly? You don't need this package then.

posted by sindresorhus almost 5 years ago

We're supporting all OS's and only want to send the -R when it's 'darwin' just because it's a nicer experience to highlight the file if we can.

Maybe the example wasn't very clear. We're actually doing the below where we patched the package to allow passing an opts.args argument then this is being used throughout our repo. But I hate having to fork our own patch for this.

const os = require('os')
const open = require('open')

module.exports = {
  open (arg, opts = {}) {
    if (os.platform() === 'darwin') {
      opts.args = '-R'
    }

    return open(arg, opts)
  },
}
posted by jennifer-shehane almost 5 years ago

So what do you do on non-macOS systems? Just open the file? If so, kinda weird to have such different behavior depending on which system it is. Just a thought.

But yes, I'm open to adding an option for this. It needs a good name though.

posted by sindresorhus almost 5 years ago

Yeah, it just opens the file.

posted by jennifer-shehane almost 5 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests