prebuild-install icon indicating copy to clipboard operation
prebuild-install copied to clipboard

How to fail completely via flags if the remote isn't available

Open reconbot opened this issue 7 years ago • 8 comments

I'd like to test if the download works. With node-pre-gyp I was able to install the package like so and ensure it downloaded and not built.

npm install serialport@beta --fallback-to-build=false

I use this in CI to ensure the state of all the builds before publishing the npm package. It's also been able to catch npm bugs on different platforms. It has been very helpful.

Since my package.json install line now reads

    "install": "prebuild-install || node-gyp rebuild",

I need to convince prebuild-install to not download and not error, or convince node-gyp to not build if it gets run.

Is there a known way to achieve this?

Thanks!

reconbot avatar Aug 07 '17 00:08 reconbot

No, this is currently not possible. The standalone check was implemented as a little help for the module developers, so they don't have to specify --build-from-source every time they want to build their modules.

@ralphtheninja I see two options here:

  1. remove the standalone path (major)
  2. add a new argument for this case like --force-download that skips the standalone check (minor).

I am tending to 1 because prebuild-install was made to download the binary. And it should only exit if a user don't want to or a download is not possible. And for developer there are still two aliases for --build-from-source --compile and -c wich should be documented :)

mathiask88 avatar Aug 07 '17 06:08 mathiask88

I need to convince prebuild-install to not download and not error, or convince node-gyp to not build if it gets run.

I was a bit confused by this. If I understand correctly, you want prebuild-install to download and if that fails it should fail?

How about adding prebuild-install --test instead, you could then have a pretest script that's being run when testing (or add another script and execute it explicitly in e.g. .travis.yml)

@mathiask88 What do you mean with "the standalone path"?

ralphtheninja avatar Aug 07 '17 11:08 ralphtheninja

@ralphtheninja I meant this behavior.

mathiask88 avatar Aug 07 '17 12:08 mathiask88

I think the --test flag would need to process.exit(0) to prevent the binary from being built from node-gyp with the recommended setup.

Unless --test would be used for testing to see if it could download the package and not actually installing the binary?

I'd prefer to keep this in the install processes so I can verify that not only it downloaded but the download works.

eg

npm install --prebuild-test
node ./ # Would fail if binary isn't present 

Funny enough this works on linux, false takes any argument and fails

node-gyp rebuild --make=false

but I don't know how to pass it through npm install

reconbot avatar Aug 07 '17 13:08 reconbot

Oh, ok I misread. I thought you want to download the binary in your dev environment, ignore my last answer then :)

mathiask88 avatar Aug 07 '17 14:08 mathiask88

Oh, ok I misread. I thought you want to download the binary in your dev environment, ignore my last answer then :)

This is my current understanding as well :)

ralphtheninja avatar Aug 07 '17 15:08 ralphtheninja

@reconbot Is this still a thing?

mathiask88 avatar Oct 24 '17 17:10 mathiask88

Yeah, unless there's been new features I don't know about. This allows me to test our build pipeline and ensure we have binaries published and useable without having to build something to test prebuild-install.

reconbot avatar Oct 26 '17 03:10 reconbot