Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Fix hanging CI builds #352

Conversation

rosen-vladimirov
Copy link
Contributor

Fix usage of plugin with npm 2

Whenever you try using the plugin with npm 2, it's postinstall script will fail, as it requires fs-extra module. However it's not been added as dependency of the plugin, so it does not exist in node_modules and require fails.
When npm 3 or later is used, the fs-extra plugin exists in the root level of node_modules as it is a dependency of fs-promise. npm 3 and later tries to flatten the dependencies tree, so fs-extra is moved in the root level and the require in the post-install script works.

In order to fix this, add the fs-extra as dependency of the plugin.

NOTE: Maybe it's worth checking why we need fs-extra, Node.js fs could do the work, but I leave it for further discussions.

Fix postinstall in CI environment

In case you are in CI environment (non-interactive terminal), the postinstall script will fail as it prompts for action (in case there's no firebase.nativescript.json). As this is one of the basic scenarios when adding a plugin (add it and try building the project), some CI or cloud builds are hanging.
So add a check if the console is interactive and use the default settings in case it is.

Whenever you try using the plugin with `npm 2`, it's postinstall script will fail, as it requires `fs-extra` module. However it's not been added as dependency of the plugin, so it does not exist in node_modules and `require` fails.
When npm 3 or later is used, the `fs-extra` plugin exists in the root level of `node_modules` as it is a dependency of `fs-promise`. npm 3 and later tries to flatten the dependencies tree, so `fs-extra` is moved in the root level and the `require` in the post-install script works.

In order to fix this, add the `fs-extra` as dependency of the plugin.

NOTE: Maybe it's worth checking why we need fs-extra, Node.js `fs` could do the work, but I leave it for further discussions.
In case you are in CI environment (non-interactive terminal), the postinstall script will fail as it prompts for action (in case there's no firebase.nativescript.json). As this is one of the basic scenarios when adding a plugin (add it and try building the project), some CI or cloud builds are hanging.
So add a check if the console is interactive and use the default settings in case it is.
@EddyVerbruggen EddyVerbruggen merged commit e79c9bf into EddyVerbruggen:master Apr 21, 2017
@EddyVerbruggen
Copy link
Owner

Thanks!

I'll push an update to npm in a minute.

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

Successfully merging this pull request may close these issues.

None yet

2 participants