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

Subcommands doesn't work on windows #88

Closed
julianduque opened this issue May 1, 2017 · 14 comments
Closed

Subcommands doesn't work on windows #88

julianduque opened this issue May 1, 2017 · 14 comments

Comments

@julianduque
Copy link
Contributor

julianduque commented May 1, 2017

The subcommand binary isn't found on windows environments

C:\> tool config get option
C:\Users\jduque\AppData\Roaming\npm\node_modules\tool\node_modules\args\index.js:342
throw err
^

Error: spawn tool.js-config ENOENT
@ntwcklng
Copy link
Collaborator

ntwcklng commented May 2, 2017

Hey, did you try this: #46?

@julianduque
Copy link
Contributor Author

@ntwcklng yes, I have the binary scripts in package.json but it fails only on Windows, Linux/mac works good

@ntwcklng
Copy link
Collaborator

ntwcklng commented May 2, 2017

Unfortunately i don't own a windows machine, can anyone else help & debug?

@TooTallNate
Copy link
Collaborator

Could be worth setting up AppVeyor tests for a tool like this.

@ntwcklng
Copy link
Collaborator

ntwcklng commented May 3, 2017

@julianduque can you please test if this works?
Replace this https://github.com/leo/args/blob/master/lib/utils.js#L281-L283
with this:

    if (process.platform === 'win32') {
      // Run binary of sub command on windows
      args.unshift(full)
      this.child = spawn(process.execPath, args, {
        stdio: 'inherit'
      });
    } else {
      // Run binary of sub command
      this.child = spawn(full, args, {
        stdio: 'inherit'
      });
    }

It should work when the binary has no .js extension

@ntwcklng
Copy link
Collaborator

I now have access to a windows machine and came up with this fix: bf22203
But it feels a bit hacky - is there another way to run the binary?

@ntwcklng
Copy link
Collaborator

cc @leo what do you think about this: bf22203

@leo
Copy link
Owner

leo commented Aug 29, 2017

Looks good to me as a start, @ntwcklng! 😊

@Gioyik
Copy link

Gioyik commented Oct 6, 2017

@ntwcklng I tested your solution but still not luck. This is what I get now:

C:\> mytool config get option
module.js:471
  throw err
  ^

Error: Cannot find module 'C:\Users\gioyik\Documents\MyProject\mytool-config.js'

The package.json of mytool is this:

  "bin": {
    "mytool": "./bin/mytool.js",
    "mytool-config": "./bin/mytool-config.js"
  },

Seems it's looking for mytool-config.js file inside the project/folder I run mytool. Hope this helps to understand what is happening.

@ntwcklng
Copy link
Collaborator

ntwcklng commented Oct 6, 2017

@Gioyik Thanks for your help! I've pushed another commit to #105 - can you check it out?

@Gioyik
Copy link

Gioyik commented Oct 6, 2017

@ntwcklng is working now. I think the PR is ready to be merge now that is working as expected on Windows.

@julianduque
Copy link
Contributor Author

Thanks @Gioyik for confirm and @ntwcklng for your work on this <3 - now let's wait for @leo review 🙇

@ntwcklng
Copy link
Collaborator

ntwcklng commented Oct 9, 2017

@Gioyik, @julianduque released in 3.0.5. Many thanks!

@Gioyik
Copy link

Gioyik commented Oct 9, 2017

@ntwcklng thank you, we appreciate the really fast answer from you and Leo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants